@twin.org/entity-storage-connector-postgresql 0.10.1-next.1 → 0.10.1-next.10

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.
@@ -1,7 +1,7 @@
1
1
  import { type IHealth, type IHealthProviderComponent } from "@twin.org/api-models";
2
2
  import { type IContextIds } from "@twin.org/context";
3
3
  import { type EntityCondition, type IEntitySchema, SortDirection } from "@twin.org/entity";
4
- import { type IEntityStorageMigrationConnector, type IMigrationOptions } from "@twin.org/entity-storage-models";
4
+ import { type IEntityStorageConnector, type IEntityStorageJoinOptions, type IEntityStorageMigrationConnector, type IMigrationOptions } from "@twin.org/entity-storage-models";
5
5
  import type { IPostgreSqlEntityStorageConnectorConstructorOptions } from "./models/IPostgreSqlEntityStorageConnectorConstructorOptions.js";
6
6
  /**
7
7
  * Class for performing entity storage operations using ql.
@@ -115,7 +115,7 @@ export declare class PostgreSqlEntityStorageConnector<T = unknown> implements IE
115
115
  */
116
116
  createTargetConnector<U>(entitySchemaName: string): Promise<PostgreSqlEntityStorageConnector<U>>;
117
117
  /**
118
- * Finalize the migration by renaming the migration table to the original table name.
118
+ * Finalize the migration by dropping the source table and renaming the migration table into its name in one transaction.
119
119
  * @param targetConnector The connector pointing to the migration table.
120
120
  * @param options The optional migration options.
121
121
  * @param loggingComponentType The node logging component type.
@@ -146,6 +146,27 @@ export declare class PostgreSqlEntityStorageConnector<T = unknown> implements IE
146
146
  entities: Partial<T>[];
147
147
  cursor?: string;
148
148
  }>;
149
+ /**
150
+ * Find all the entities which match the conditions, attaching to each one the entities from a
151
+ * second storage connector whose join property matches. The join behaves like a left join by
152
+ * default, a primary entity with no matches is still returned with an empty joined list, unless
153
+ * joinRequired asks for an inner join and those entities are left out altogether. Both connectors
154
+ * must be PostgreSQL connectors reading from the same database so the work can be done in a
155
+ * single statement.
156
+ * @param joinConnector The connector holding the entities to join to.
157
+ * @param joinOptions The properties to join on, the conditions, sort order, projection and
158
+ * paging for the primary entities, the optional grouping and group conditions, and the optional
159
+ * conditions, sort order and projection for the joined entities.
160
+ * @returns All the entities for the storage matching the conditions with their joined entities,
161
+ * and a cursor which can be used to request more entities.
162
+ * @throws GeneralError if the join connector does not read from the same server and database.
163
+ */
164
+ queryJoin<U>(joinConnector: IEntityStorageConnector<U>, joinOptions: IEntityStorageJoinOptions<T, U>): Promise<{
165
+ entities: (Partial<T> & {
166
+ joined: Partial<U>[];
167
+ })[];
168
+ cursor?: string;
169
+ }>;
149
170
  /**
150
171
  * Count all the entities which match the conditions.
151
172
  * @param conditions The optional conditions to match for the entities.
package/docs/changelog.md CHANGED
@@ -1,5 +1,149 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.10.1-next.10](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.9...entity-storage-connector-postgresql-v0.10.1-next.10) (2026-09-23)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **entity-storage-connector-postgresql:** Synchronize repo versions
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.9 to 0.10.1-next.10
16
+ * devDependencies
17
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.9 to 0.10.1-next.10
18
+
19
+ ## [0.10.1-next.9](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.8...entity-storage-connector-postgresql-v0.10.1-next.9) (2026-09-22)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * swap the migrated table into place atomically and fail loudly after an interrupted finalize ([#300](https://github.com/iotaledger/twin-entity-storage/issues/300)) ([0a59fb4](https://github.com/iotaledger/twin-entity-storage/commit/0a59fb452bafee9acfb730c0a3a3779a58fd1f3d))
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * The following workspace dependencies were updated
30
+ * dependencies
31
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.8 to 0.10.1-next.9
32
+ * devDependencies
33
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.8 to 0.10.1-next.9
34
+
35
+ ## [0.10.1-next.8](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.7...entity-storage-connector-postgresql-v0.10.1-next.8) (2026-09-22)
36
+
37
+
38
+ ### Miscellaneous Chores
39
+
40
+ * **entity-storage-connector-postgresql:** Synchronize repo versions
41
+
42
+
43
+ ### Dependencies
44
+
45
+ * The following workspace dependencies were updated
46
+ * dependencies
47
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.7 to 0.10.1-next.8
48
+ * devDependencies
49
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.7 to 0.10.1-next.8
50
+
51
+ ## [0.10.1-next.7](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.6...entity-storage-connector-postgresql-v0.10.1-next.7) (2026-09-22)
52
+
53
+
54
+ ### Bug Fixes
55
+
56
+ * project properties in common group join ([b90389d](https://github.com/iotaledger/twin-entity-storage/commit/b90389dd7df593b560faf2299e912c25a66bf6ee))
57
+
58
+
59
+ ### Dependencies
60
+
61
+ * The following workspace dependencies were updated
62
+ * dependencies
63
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.6 to 0.10.1-next.7
64
+ * devDependencies
65
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.6 to 0.10.1-next.7
66
+
67
+ ## [0.10.1-next.6](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.5...entity-storage-connector-postgresql-v0.10.1-next.6) (2026-09-21)
68
+
69
+
70
+ ### Features
71
+
72
+ * join and group ([#295](https://github.com/iotaledger/twin-entity-storage/issues/295)) ([e0103b3](https://github.com/iotaledger/twin-entity-storage/commit/e0103b3af5d9d0d37d4f590c6f31993d2c7e6508))
73
+
74
+
75
+ ### Dependencies
76
+
77
+ * The following workspace dependencies were updated
78
+ * dependencies
79
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.5 to 0.10.1-next.6
80
+ * devDependencies
81
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.5 to 0.10.1-next.6
82
+
83
+ ## [0.10.1-next.5](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.4...entity-storage-connector-postgresql-v0.10.1-next.5) (2026-09-18)
84
+
85
+
86
+ ### Miscellaneous Chores
87
+
88
+ * **entity-storage-connector-postgresql:** Synchronize repo versions
89
+
90
+
91
+ ### Dependencies
92
+
93
+ * The following workspace dependencies were updated
94
+ * dependencies
95
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.4 to 0.10.1-next.5
96
+ * devDependencies
97
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.4 to 0.10.1-next.5
98
+
99
+ ## [0.10.1-next.4](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.3...entity-storage-connector-postgresql-v0.10.1-next.4) (2026-09-18)
100
+
101
+
102
+ ### Features
103
+
104
+ * add StartsWith comparison operator to all connectors ([#282](https://github.com/iotaledger/twin-entity-storage/issues/282)) ([fbb0b4a](https://github.com/iotaledger/twin-entity-storage/commit/fbb0b4a1a3d3f8ba80e8371bd2ec3a75260b9dd3))
105
+
106
+
107
+ ### Dependencies
108
+
109
+ * The following workspace dependencies were updated
110
+ * dependencies
111
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.3 to 0.10.1-next.4
112
+ * devDependencies
113
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.3 to 0.10.1-next.4
114
+
115
+ ## [0.10.1-next.3](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.2...entity-storage-connector-postgresql-v0.10.1-next.3) (2026-09-18)
116
+
117
+
118
+ ### Features
119
+
120
+ * index include partitionid ([#280](https://github.com/iotaledger/twin-entity-storage/issues/280)) ([26d36e1](https://github.com/iotaledger/twin-entity-storage/commit/26d36e1c40207feb03c797b0ab00b485a1ae5cda))
121
+
122
+
123
+ ### Dependencies
124
+
125
+ * The following workspace dependencies were updated
126
+ * dependencies
127
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.2 to 0.10.1-next.3
128
+ * devDependencies
129
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.2 to 0.10.1-next.3
130
+
131
+ ## [0.10.1-next.2](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.1...entity-storage-connector-postgresql-v0.10.1-next.2) (2026-09-17)
132
+
133
+
134
+ ### Miscellaneous Chores
135
+
136
+ * **entity-storage-connector-postgresql:** Synchronize repo versions
137
+
138
+
139
+ ### Dependencies
140
+
141
+ * The following workspace dependencies were updated
142
+ * dependencies
143
+ * @twin.org/entity-storage-models bumped from 0.10.1-next.1 to 0.10.1-next.2
144
+ * devDependencies
145
+ * @twin.org/entity-storage-connector-memory bumped from 0.10.1-next.1 to 0.10.1-next.2
146
+
3
147
  ## [0.10.1-next.1](https://github.com/iotaledger/twin-entity-storage/compare/entity-storage-connector-postgresql-v0.10.1-next.0...entity-storage-connector-postgresql-v0.10.1-next.1) (2026-09-17)
4
148
 
5
149
 
@@ -423,7 +423,7 @@ A new connector configured with a migration table name.
423
423
 
424
424
  > **finalizeMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<`PostgreSqlEntityStorageConnector`\<`U`\>\>
425
425
 
426
- Finalize the migration by renaming the migration table to the original table name.
426
+ Finalize the migration by dropping the source table and renaming the migration table into its name in one transaction.
427
427
 
428
428
  #### Type Parameters
429
429
 
@@ -556,6 +556,56 @@ and a cursor which can be used to request more entities.
556
556
 
557
557
  ***
558
558
 
559
+ ### queryJoin() {#queryjoin}
560
+
561
+ > **queryJoin**\<`U`\>(`joinConnector`, `joinOptions`): `Promise`\<\{ `entities`: `Partial`\<`T`\> & `object`[]; `cursor?`: `string`; \}\>
562
+
563
+ Find all the entities which match the conditions, attaching to each one the entities from a
564
+ second storage connector whose join property matches. The join behaves like a left join by
565
+ default, a primary entity with no matches is still returned with an empty joined list, unless
566
+ joinRequired asks for an inner join and those entities are left out altogether. Both connectors
567
+ must be PostgreSQL connectors reading from the same database so the work can be done in a
568
+ single statement.
569
+
570
+ #### Type Parameters
571
+
572
+ ##### U
573
+
574
+ `U`
575
+
576
+ #### Parameters
577
+
578
+ ##### joinConnector
579
+
580
+ `IEntityStorageConnector`\<`U`\>
581
+
582
+ The connector holding the entities to join to.
583
+
584
+ ##### joinOptions
585
+
586
+ `IEntityStorageJoinOptions`\<`T`, `U`\>
587
+
588
+ The properties to join on, the conditions, sort order, projection and
589
+ paging for the primary entities, the optional grouping and group conditions, and the optional
590
+ conditions, sort order and projection for the joined entities.
591
+
592
+ #### Returns
593
+
594
+ `Promise`\<\{ `entities`: `Partial`\<`T`\> & `object`[]; `cursor?`: `string`; \}\>
595
+
596
+ All the entities for the storage matching the conditions with their joined entities,
597
+ and a cursor which can be used to request more entities.
598
+
599
+ #### Throws
600
+
601
+ GeneralError if the join connector does not read from the same server and database.
602
+
603
+ #### Implementation of
604
+
605
+ `IEntityStorageMigrationConnector.queryJoin`
606
+
607
+ ***
608
+
559
609
  ### count() {#count}
560
610
 
561
611
  > **count**(`conditions?`): `Promise`\<`number`\>
package/locales/en.json CHANGED
@@ -7,8 +7,7 @@
7
7
  "tableExists": "Table \"{tableName}\" created or it already exists",
8
8
  "tableDropping": "Dropping table \"{tableName}\"",
9
9
  "tableDropped": "Table \"{tableName}\" dropped",
10
- "legacyIndexDropped": "Legacy index \"{indexName}\" dropped from table \"{tableName}\", \"{newIndexName}\" already covers the column",
11
- "legacyIndexRenamed": "Legacy index \"{indexName}\" renamed to \"{newIndexName}\" on table \"{tableName}\""
10
+ "legacyIndexDropped": "Legacy index \"{indexName}\" dropped from table \"{tableName}\", \"{newIndexName}\" now covers the column"
12
11
  }
13
12
  },
14
13
  "warn": {
@@ -26,6 +25,8 @@
26
25
  "getFailed": "Unable to get entity \"{id}\"",
27
26
  "removeFailed": "Unable to remove entity \"{id}\"",
28
27
  "queryFailed": "The query failed",
28
+ "queryJoinFailed": "The join query failed",
29
+ "joinConnectorMismatch": "The join connector must be a PostgreSQL connector reading from the same server and database \"{database}\"",
29
30
  "comparisonNotSupported": "Comparison operator \"{comparison}\" is not supported",
30
31
  "conditionalNotSupported": "Conditional operator \"{operator}\" is not supported",
31
32
  "entitySchemaPropertiesUndefined": "The entity schema properties are undefined",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-connector-postgresql",
3
- "version": "0.10.1-next.1",
3
+ "version": "0.10.1-next.10",
4
4
  "description": "PostgreSQL connector for relational persistence and advanced SQL features.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,7 @@
18
18
  "@twin.org/context": "next",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/entity": "next",
21
- "@twin.org/entity-storage-models": "0.10.1-next.1",
21
+ "@twin.org/entity-storage-models": "0.10.1-next.10",
22
22
  "@twin.org/logging-models": "next",
23
23
  "@twin.org/nameof": "next",
24
24
  "postgres": "3.4.9"