@noldova/context.data.sql 0.0.0-stage → 0.0.7

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.
Files changed (56) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -2
  3. package/api/index.d.ts +664 -0
  4. package/api/index.js +31 -0
  5. package/api/index.js.map +1 -0
  6. package/enums/column-type.js +13 -0
  7. package/enums/column-type.js.map +1 -0
  8. package/models/operations/create-index-operation.js +19 -0
  9. package/models/operations/create-index-operation.js.map +1 -0
  10. package/models/operations/create-table-operation.js +19 -0
  11. package/models/operations/create-table-operation.js.map +1 -0
  12. package/models/operations/schema-operation.js +10 -0
  13. package/models/operations/schema-operation.js.map +1 -0
  14. package/models/operations/sql-statement-operation.js +22 -0
  15. package/models/operations/sql-statement-operation.js.map +1 -0
  16. package/models/schema/column-builder.js +25 -0
  17. package/models/schema/column-builder.js.map +1 -0
  18. package/models/schema/column.js +21 -0
  19. package/models/schema/column.js.map +1 -0
  20. package/models/schema/columns-builder.js +21 -0
  21. package/models/schema/columns-builder.js.map +1 -0
  22. package/models/schema/constraints-builder.js +29 -0
  23. package/models/schema/constraints-builder.js.map +1 -0
  24. package/models/schema/foreign-key.js +23 -0
  25. package/models/schema/foreign-key.js.map +1 -0
  26. package/models/schema/migration-builder.js +45 -0
  27. package/models/schema/migration-builder.js.map +1 -0
  28. package/models/schema/primary-key.js +18 -0
  29. package/models/schema/primary-key.js.map +1 -0
  30. package/models/schema/table.js +25 -0
  31. package/models/schema/table.js.map +1 -0
  32. package/models/sql-connection.js +46 -0
  33. package/models/sql-connection.js.map +1 -0
  34. package/models/sql-migration.js +14 -0
  35. package/models/sql-migration.js.map +1 -0
  36. package/models/sql-query.js +22 -0
  37. package/models/sql-query.js.map +1 -0
  38. package/models/sql-session.js +10 -0
  39. package/models/sql-session.js.map +1 -0
  40. package/models/sql-transaction.js +36 -0
  41. package/models/sql-transaction.js.map +1 -0
  42. package/package.json +25 -4
  43. package/resources.js +58 -0
  44. package/resources.js.map +1 -0
  45. package/services/sql-change-feed.js +54 -0
  46. package/services/sql-change-feed.js.map +1 -0
  47. package/services/sql-dialect.js +49 -0
  48. package/services/sql-dialect.js.map +1 -0
  49. package/services/sql-migration-history.js +32 -0
  50. package/services/sql-migration-history.js.map +1 -0
  51. package/services/sql-migrator.js +37 -0
  52. package/services/sql-migrator.js.map +1 -0
  53. package/services/sql-provider.js +19 -0
  54. package/services/sql-provider.js.map +1 -0
  55. package/types/column-selector.js +9 -0
  56. package/types/column-selector.js.map +1 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) Noldova
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
1
+ # noldova.context.data.sql
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The data model of `noldova.context.data` over SQL: a schema and migration
4
+ builder, dialects that render it with every identifier quoted, and SQL
5
+ connections, transactions, migrations and a change feed over one database
6
+ session a provider supplies. A connection runs its statements and
7
+ transactions one at a time; inside a transaction's action, every statement
8
+ goes through the transaction the action receives, never the connection,
9
+ whose calls would wait for the action to end.
10
+
11
+ `noldova.context.data.sql.sqlite` and `noldova.context.data.sql.postgresql`
12
+ provide the sessions and dialects of each database.
13
+
14
+ ## Install
15
+
16
+ ```bash
17
+ npm install @noldova/context.data.sql
18
+ ```
19
+
20
+ ## Use
21
+
22
+ ```ts
23
+ import { ColumnType, type MigrationBuilder, SqlMigration, SqlQuery } from "@noldova/context.data.sql";
24
+
25
+ type Note = { readonly id: string; readonly text: string };
26
+
27
+ class NotesMigration extends SqlMigration {
28
+ public constructor() {
29
+ super("20260908130000_Notes");
30
+ }
31
+
32
+ public override apply(builder: MigrationBuilder): void {
33
+ builder.createTable<Note>("notes",
34
+ table => {
35
+ table.addColumn(t => t.id, ColumnType.Text);
36
+ table.addColumn(t => t.text, ColumnType.Text);
37
+ },
38
+ constraints => constraints.addPrimaryKey(t => t.id));
39
+ }
40
+ }
41
+
42
+ await connection.runInTransactionAsync(async transaction => {
43
+ await transaction.executeAsync(new SqlQuery("INSERT INTO \"notes\" (\"id\", \"text\") VALUES (?, ?)", ["1", "a"]));
44
+ });
45
+ ```
46
+
47
+ The declaration file `api/index.d.ts` documents every member with its
48
+ contract.
49
+
50
+ ## License
51
+
52
+ MIT; see `LICENSE`.