@smartive/graphql-magic 23.9.0 → 23.10.0-next.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,5 @@
|
|
|
1
|
-
## [23.
|
|
1
|
+
## [23.10.0-next.1](https://github.com/smartive/graphql-magic/compare/v23.9.0...v23.10.0-next.1) (2026-03-07)
|
|
2
2
|
|
|
3
3
|
### Features
|
|
4
4
|
|
|
5
|
-
*
|
|
5
|
+
* extend exclude constraint with message, add DELETE event to constraint_trigger ([b8ac6ca](https://github.com/smartive/graphql-magic/commit/b8ac6ca43a62f0a32a35e65a07771325ab9d296c))
|
|
@@ -201,13 +201,14 @@ export type ConstraintDefinition = {
|
|
|
201
201
|
operator: '&&';
|
|
202
202
|
})[];
|
|
203
203
|
where?: string;
|
|
204
|
+
message?: string;
|
|
204
205
|
deferrable?: 'INITIALLY DEFERRED' | 'INITIALLY IMMEDIATE';
|
|
205
206
|
notValid?: boolean;
|
|
206
207
|
} | {
|
|
207
208
|
kind: 'constraint_trigger';
|
|
208
209
|
name: string;
|
|
209
210
|
when: 'AFTER' | 'BEFORE';
|
|
210
|
-
events: readonly ('INSERT' | 'UPDATE')[];
|
|
211
|
+
events: readonly ('INSERT' | 'UPDATE' | 'DELETE')[];
|
|
211
212
|
forEach: 'ROW' | 'STATEMENT';
|
|
212
213
|
deferrable?: 'INITIALLY DEFERRED' | 'INITIALLY IMMEDIATE';
|
|
213
214
|
function: {
|
package/docs/docs/2-models.md
CHANGED
|
@@ -144,13 +144,13 @@ Optional array of database constraints for this entity. Supported kinds: `check`
|
|
|
144
144
|
|
|
145
145
|
Enforce non-overlapping values per group (e.g. no overlapping date ranges per portfolio). Requires the `btree_gist` extension (created automatically when needed).
|
|
146
146
|
|
|
147
|
-
- **`name`**, **`using`** (typically `'gist'`), **`elements`** (e.g. `{ column: 'portfolioId', operator: '=' }` for grouping, or `{ expression: 'tsrange(...)', operator: '&&' }` for ranges), **`where`** (optional), **`deferrable`** (optional), **`notValid`** (optional; PostgreSQL 15+).
|
|
147
|
+
- **`name`**, **`using`** (typically `'gist'`), **`elements`** (e.g. `{ column: 'portfolioId', operator: '=' }` for grouping, or `{ expression: 'tsrange(...)', operator: '&&' }` for ranges), **`where`** (optional), **`message`** (optional; human-readable message for when the constraint fails; not used by graphql-magic; available for application-level error mapping), **`deferrable`** (optional), **`notValid`** (optional; PostgreSQL 15+).
|
|
148
148
|
|
|
149
149
|
#### Constraint triggers (`kind: 'constraint_trigger'`)
|
|
150
150
|
|
|
151
151
|
Deferrable triggers for validation (e.g. contiguous periods). The function must be defined in `functions.ts`.
|
|
152
152
|
|
|
153
|
-
- **`name`**, **`when`** (`'AFTER'` or `'BEFORE'`), **`events`** (`['INSERT', 'UPDATE']
|
|
153
|
+
- **`name`**, **`when`** (`'AFTER'` or `'BEFORE'`), **`events`** (`['INSERT', 'UPDATE', 'DELETE']`; any combination), **`forEach`** (`'ROW'` or `'STATEMENT'`), **`deferrable`** (optional), **`function`** (`{ name: string; args?: string[] }`).
|
|
154
154
|
|
|
155
155
|
Example: ensure a numeric field is non-negative and a status is one of the allowed values:
|
|
156
156
|
|
package/package.json
CHANGED
|
@@ -1287,7 +1287,7 @@ export class MigrationGenerator {
|
|
|
1287
1287
|
constraintName: string,
|
|
1288
1288
|
entry: {
|
|
1289
1289
|
when: 'AFTER' | 'BEFORE';
|
|
1290
|
-
events: readonly ('INSERT' | 'UPDATE')[];
|
|
1290
|
+
events: readonly ('INSERT' | 'UPDATE' | 'DELETE')[];
|
|
1291
1291
|
forEach: 'ROW' | 'STATEMENT';
|
|
1292
1292
|
deferrable?: 'INITIALLY DEFERRED' | 'INITIALLY IMMEDIATE';
|
|
1293
1293
|
function: { name: string; args?: string[] };
|
|
@@ -1333,7 +1333,7 @@ export class MigrationGenerator {
|
|
|
1333
1333
|
constraintName: string,
|
|
1334
1334
|
entry: {
|
|
1335
1335
|
when: 'AFTER' | 'BEFORE';
|
|
1336
|
-
events: readonly ('INSERT' | 'UPDATE')[];
|
|
1336
|
+
events: readonly ('INSERT' | 'UPDATE' | 'DELETE')[];
|
|
1337
1337
|
forEach: 'ROW' | 'STATEMENT';
|
|
1338
1338
|
deferrable?: 'INITIALLY DEFERRED' | 'INITIALLY IMMEDIATE';
|
|
1339
1339
|
function: { name: string; args?: string[] };
|
|
@@ -188,6 +188,7 @@ export type ConstraintDefinition =
|
|
|
188
188
|
using: 'gist';
|
|
189
189
|
elements: readonly ({ column: string; operator: '=' } | { expression: string; operator: '&&' })[];
|
|
190
190
|
where?: string;
|
|
191
|
+
message?: string;
|
|
191
192
|
deferrable?: 'INITIALLY DEFERRED' | 'INITIALLY IMMEDIATE';
|
|
192
193
|
notValid?: boolean;
|
|
193
194
|
}
|
|
@@ -195,7 +196,7 @@ export type ConstraintDefinition =
|
|
|
195
196
|
kind: 'constraint_trigger';
|
|
196
197
|
name: string;
|
|
197
198
|
when: 'AFTER' | 'BEFORE';
|
|
198
|
-
events: readonly ('INSERT' | 'UPDATE')[];
|
|
199
|
+
events: readonly ('INSERT' | 'UPDATE' | 'DELETE')[];
|
|
199
200
|
forEach: 'ROW' | 'STATEMENT';
|
|
200
201
|
deferrable?: 'INITIALLY DEFERRED' | 'INITIALLY IMMEDIATE';
|
|
201
202
|
function: { name: string; args?: string[] };
|