Skip to content

Commit 89fcfbd

Browse files
feat(export): excludeCategories filtering in GraphQL export mode
Adds category to the migrate-client schema/ORM (SqlAction field, filter, orderBy) and filters sql_actions server-side in exportGraphQL via or: [category isNull, category notIn excludeCategories], keeping null-category rows. CLI now passes --exclude-categories in both modes.
1 parent 1f967d5 commit 89fcfbd

5 files changed

Lines changed: 40 additions & 8 deletions

File tree

pgpm/cli/src/commands/export.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Options:
2424
--extensionName <name> Extension name
2525
--metaExtensionName <name> Meta extension name (default: svc)
2626
--exclude-categories <list> Comma-separated sql_actions categories to omit
27-
(e.g. security,permissions,auth,memberships). SQL mode only.
27+
(e.g. security,permissions,auth,memberships). Works in SQL and GraphQL modes.
2828
--cwd <directory> Working directory (default: current directory)
2929
3030
Examples:
@@ -179,7 +179,8 @@ export default async (
179179
metaExtensionName,
180180
prompter,
181181
argv,
182-
username
182+
username,
183+
excludeCategories
183184
});
184185
} else {
185186
// =========================================================================

pgpm/export/src/export-graphql.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ export interface ExportGraphQLOptions {
7070
username?: string;
7171
serviceOutdir?: string;
7272
skipSchemaRenaming?: boolean;
73+
/**
74+
* sql_actions categories to exclude from the export (e.g. ['security',
75+
* 'permissions']). Rows whose category matches are omitted; rows with a
76+
* null category are always kept.
77+
*/
78+
excludeCategories?: string[];
7379
}
7480

7581
export const exportGraphQL = async ({
@@ -94,7 +100,8 @@ export const exportGraphQL = async ({
94100
repoName,
95101
username,
96102
serviceOutdir,
97-
skipSchemaRenaming = false
103+
skipSchemaRenaming = false,
104+
excludeCategories
98105
}: ExportGraphQLOptions): Promise<void> => {
99106
const normalizedOutdir = normalizeOutdir(outdir);
100107
const svcOutdir = normalizeOutdir(serviceOutdir || outdir);
@@ -147,10 +154,19 @@ export const exportGraphQL = async ({
147154
actionName: true,
148155
actionId: true,
149156
actorId: true,
150-
payload: true
157+
payload: true,
158+
category: true
151159
},
152160
where: {
153-
databaseId: { equalTo: databaseId }
161+
databaseId: { equalTo: databaseId },
162+
...(excludeCategories && excludeCategories.length > 0
163+
? {
164+
or: [
165+
{ category: { isNull: true } },
166+
{ category: { notIn: excludeCategories } }
167+
]
168+
}
169+
: {})
154170
},
155171
orderBy: ['ID_ASC'],
156172
first: PAGE_SIZE,

sdk/migrate-client/schemas/migrate.graphql

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ type SqlAction {
662662
actionId: UUID
663663
actionName: String
664664
actorId: UUID
665+
category: String
665666
content: String
666667
createdAt: Datetime
667668
databaseId: UUID
@@ -716,6 +717,9 @@ input SqlActionFilter {
716717
"""Checks for all expressions in this list."""
717718
and: [SqlActionFilter!]
718719

720+
"""Filter by the object’s `category` field."""
721+
category: StringFilter
722+
719723
"""Filter by the object’s `content` field."""
720724
content: StringFilter
721725

@@ -758,6 +762,8 @@ enum SqlActionOrderBy {
758762
ACTION_NAME_DESC
759763
ACTOR_ID_ASC
760764
ACTOR_ID_DESC
765+
CATEGORY_ASC
766+
CATEGORY_DESC
761767
CONTENT_ASC
762768
CONTENT_DESC
763769
CREATED_AT_ASC

sdk/migrate-client/src/migrate/orm/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ CRUD operations for SqlAction records.
7878
| `actionId` | UUID | Yes |
7979
| `actionName` | String | Yes |
8080
| `actorId` | UUID | Yes |
81+
| `category` | String | Yes |
8182
| `content` | String | Yes |
8283
| `createdAt` | Datetime | No |
8384
| `databaseId` | UUID | Yes |
@@ -93,13 +94,13 @@ CRUD operations for SqlAction records.
9394

9495
```typescript
9596
// List all sqlAction records
96-
const items = await db.sqlAction.findMany({ select: { actionId: true, actionName: true, actorId: true, content: true, createdAt: true, databaseId: true, deploy: true, deps: true, id: true, name: true, payload: true, revert: true, verify: true } }).execute();
97+
const items = await db.sqlAction.findMany({ select: { actionId: true, actionName: true, actorId: true, category: true, content: true, createdAt: true, databaseId: true, deploy: true, deps: true, id: true, name: true, payload: true, revert: true, verify: true } }).execute();
9798

9899
// Get one by id
99-
const item = await db.sqlAction.findOne({ id: '<Int>', select: { actionId: true, actionName: true, actorId: true, content: true, createdAt: true, databaseId: true, deploy: true, deps: true, id: true, name: true, payload: true, revert: true, verify: true } }).execute();
100+
const item = await db.sqlAction.findOne({ id: '<Int>', select: { actionId: true, actionName: true, actorId: true, category: true, content: true, createdAt: true, databaseId: true, deploy: true, deps: true, id: true, name: true, payload: true, revert: true, verify: true } }).execute();
100101

101102
// Create
102-
const created = await db.sqlAction.create({ data: { actionId: '<UUID>', actionName: '<String>', actorId: '<UUID>', content: '<String>', databaseId: '<UUID>', deploy: '<String>', deps: '<String>', name: '<String>', payload: '<JSON>', revert: '<String>', verify: '<String>' }, select: { id: true } }).execute();
103+
const created = await db.sqlAction.create({ data: { actionId: '<UUID>', actionName: '<String>', actorId: '<UUID>', category: '<String>', content: '<String>', databaseId: '<UUID>', deploy: '<String>', deps: '<String>', name: '<String>', payload: '<JSON>', revert: '<String>', verify: '<String>' }, select: { id: true } }).execute();
103104

104105
// Update
105106
const updated = await db.sqlAction.update({ where: { id: '<Int>' }, data: { actionId: '<UUID>' }, select: { id: true } }).execute();

sdk/migrate-client/src/migrate/orm/input-types.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export interface SqlAction {
250250
actionId?: string | null;
251251
actionName?: string | null;
252252
actorId?: string | null;
253+
category?: string | null;
253254
content?: string | null;
254255
createdAt?: string | null;
255256
databaseId?: string | null;
@@ -299,6 +300,7 @@ export type SqlActionSelect = {
299300
actionId?: boolean;
300301
actionName?: boolean;
301302
actorId?: boolean;
303+
category?: boolean;
302304
content?: boolean;
303305
createdAt?: boolean;
304306
databaseId?: boolean;
@@ -354,6 +356,8 @@ export interface SqlActionFilter {
354356
actorId?: UUIDFilter;
355357
/** Checks for all expressions in this list. */
356358
and?: SqlActionFilter[];
359+
/** Filter by the object’s `category` field. */
360+
category?: StringFilter;
357361
/** Filter by the object’s `content` field. */
358362
content?: StringFilter;
359363
/** Filter by the object’s `createdAt` field. */
@@ -413,6 +417,8 @@ export type SqlActionOrderBy =
413417
| 'ACTION_NAME_DESC'
414418
| 'ACTOR_ID_ASC'
415419
| 'ACTOR_ID_DESC'
420+
| 'CATEGORY_ASC'
421+
| 'CATEGORY_DESC'
416422
| 'CONTENT_ASC'
417423
| 'CONTENT_DESC'
418424
| 'CREATED_AT_ASC'
@@ -479,6 +485,7 @@ export interface CreateSqlActionInput {
479485
actionId: string;
480486
actionName?: string;
481487
actorId: string;
488+
category?: string;
482489
content?: string;
483490
databaseId: string;
484491
deploy?: string;
@@ -493,6 +500,7 @@ export interface SqlActionPatch {
493500
actionId?: string | null;
494501
actionName?: string | null;
495502
actorId?: string | null;
503+
category?: string | null;
496504
content?: string | null;
497505
databaseId?: string | null;
498506
deploy?: string | null;

0 commit comments

Comments
 (0)