diff --git a/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap b/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap index 4e96b9c09..e983cdc40 100644 --- a/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap +++ b/graphql/codegen/src/__tests__/codegen/__snapshots__/client-generator.test.ts.snap @@ -276,7 +276,7 @@ export interface PageInfo { endCursor?: string | null; } -export interface FindManyArgs { +export interface FindManyArgs { select?: TSelect; where?: TWhere; condition?: TCondition; @@ -288,7 +288,7 @@ export interface FindManyArgs { offset?: number; } -export interface FindFirstArgs { +export interface FindFirstArgs { select?: TSelect; where?: TWhere; condition?: TCondition; diff --git a/graphql/codegen/src/core/codegen/orm/index.ts b/graphql/codegen/src/core/codegen/orm/index.ts index 5b1234d50..31a641b2f 100644 --- a/graphql/codegen/src/core/codegen/orm/index.ts +++ b/graphql/codegen/src/core/codegen/orm/index.ts @@ -66,6 +66,7 @@ export interface GenerateOrmResult { export function generateOrm(options: GenerateOrmOptions): GenerateOrmResult { const { tables, customOperations, sharedTypesPath } = options; const commentsEnabled = options.config.codegen?.comments !== false; + const conditionEnabled = options.config.codegen?.condition !== false; const files: GeneratedFile[] = []; // Use shared types when a sharedTypesPath is provided (unified output mode) @@ -91,7 +92,7 @@ export function generateOrm(options: GenerateOrmOptions): GenerateOrmResult { }); // 2. Generate model files - const modelFiles = generateAllModelFiles(tables, useSharedTypes); + const modelFiles = generateAllModelFiles(tables, useSharedTypes, { condition: conditionEnabled }); for (const modelFile of modelFiles) { files.push({ path: `models/${modelFile.fileName}`, @@ -140,6 +141,7 @@ export function generateOrm(options: GenerateOrmOptions): GenerateOrmResult { tables, usedPayloadTypes, commentsEnabled, + { condition: conditionEnabled }, ); files.push({ path: inputTypesFile.fileName, diff --git a/graphql/codegen/src/core/codegen/orm/input-types-generator.ts b/graphql/codegen/src/core/codegen/orm/input-types-generator.ts index 4a765433b..451ded7fc 100644 --- a/graphql/codegen/src/core/codegen/orm/input-types-generator.ts +++ b/graphql/codegen/src/core/codegen/orm/input-types-generator.ts @@ -1572,9 +1572,10 @@ function generateCustomInputTypes( usedInputTypes: Set, tableCrudTypes?: Set, comments: boolean = true, + alreadyGeneratedTypes?: Set, ): t.Statement[] { const statements: t.Statement[] = []; - const generatedTypes = new Set(); + const generatedTypes = new Set(alreadyGeneratedTypes ?? []); const typesToGenerate = new Set(Array.from(usedInputTypes)); // Filter out types we've already generated (exact matches for table CRUD types only) @@ -1969,7 +1970,9 @@ export function generateInputTypesFile( tables?: CleanTable[], usedPayloadTypes?: Set, comments: boolean = true, + options?: { condition?: boolean }, ): GeneratedInputTypesFile { + const conditionEnabled = options?.condition !== false; const statements: t.Statement[] = []; const tablesList = tables ?? []; const hasTables = tablesList.length > 0; @@ -2006,7 +2009,9 @@ export function generateInputTypesFile( // 4b. Table condition types (simple equality filter) // Pass typeRegistry to merge plugin-injected condition fields // (e.g., vectorEmbedding from VectorSearchPlugin) - statements.push(...generateTableConditionTypes(tablesList, typeRegistry)); + if (conditionEnabled) { + statements.push(...generateTableConditionTypes(tablesList, typeRegistry)); + } // 5. OrderBy types // Pass typeRegistry to merge plugin-injected orderBy values @@ -2024,7 +2029,7 @@ export function generateInputTypesFile( // 7. Custom input types from TypeRegistry // Also include any extra types referenced by plugin-injected condition fields const mergedUsedInputTypes = new Set(usedInputTypes); - if (hasTables) { + if (hasTables && conditionEnabled) { const conditionExtraTypes = collectConditionExtraInputTypes( tablesList, typeRegistry, @@ -2034,8 +2039,13 @@ export function generateInputTypesFile( } } const tableCrudTypes = tables ? buildTableCrudTypeNames(tables) : undefined; + // Pass customScalarTypes + enumTypes as already-generated to avoid duplicate declarations + const alreadyGenerated = new Set([ + ...customScalarTypes, + ...enumTypes, + ]); statements.push( - ...generateCustomInputTypes(typeRegistry, mergedUsedInputTypes, tableCrudTypes, comments), + ...generateCustomInputTypes(typeRegistry, mergedUsedInputTypes, tableCrudTypes, comments, alreadyGenerated), ); // 8. Payload/return types for custom operations diff --git a/graphql/codegen/src/core/codegen/orm/model-generator.ts b/graphql/codegen/src/core/codegen/orm/model-generator.ts index 66c591b34..d3862a332 100644 --- a/graphql/codegen/src/core/codegen/orm/model-generator.ts +++ b/graphql/codegen/src/core/codegen/orm/model-generator.ts @@ -164,7 +164,9 @@ function strictSelectGuard(selectTypeName: string): t.TSType { export function generateModelFile( table: CleanTable, _useSharedTypes: boolean, + options?: { condition?: boolean }, ): GeneratedModelFile { + const conditionEnabled = options?.condition !== false; const { typeName, singularName, pluralName } = getTableNames(table); const modelName = `${typeName}Model`; const baseFileName = lcFirst(typeName); @@ -175,7 +177,7 @@ export function generateModelFile( const selectTypeName = `${typeName}Select`; const relationTypeName = `${typeName}WithRelations`; const whereTypeName = getFilterTypeName(table); - const conditionTypeName = `${typeName}Condition`; + const conditionTypeName = conditionEnabled ? `${typeName}Condition` : undefined; const orderByTypeName = getOrderByTypeName(table); const createInputTypeName = `Create${typeName}Input`; const updateInputTypeName = `Update${typeName}Input`; @@ -221,20 +223,21 @@ export function generateModelFile( true, ), ); + const inputTypeImports = [ + typeName, + relationTypeName, + selectTypeName, + whereTypeName, + ...(conditionTypeName ? [conditionTypeName] : []), + orderByTypeName, + createInputTypeName, + updateInputTypeName, + patchTypeName, + ]; statements.push( createImportDeclaration( '../input-types', - [ - typeName, - relationTypeName, - selectTypeName, - whereTypeName, - conditionTypeName, - orderByTypeName, - createInputTypeName, - updateInputTypeName, - patchTypeName, - ], + inputTypeImports, true, ), ); @@ -266,15 +269,20 @@ export function generateModelFile( // ── findMany ─────────────────────────────────────────────────────────── { + const findManyTypeArgs: Array<(sel: t.TSType) => t.TSType> = [ + (sel: t.TSType) => sel, + () => t.tsTypeReference(t.identifier(whereTypeName)), + ...(conditionTypeName + ? [() => t.tsTypeReference(t.identifier(conditionTypeName))] + : []), + () => t.tsTypeReference(t.identifier(orderByTypeName)), + ]; const argsType = (sel: t.TSType) => t.tsTypeReference( t.identifier('FindManyArgs'), - t.tsTypeParameterInstantiation([ - sel, - t.tsTypeReference(t.identifier(whereTypeName)), - t.tsTypeReference(t.identifier(conditionTypeName)), - t.tsTypeReference(t.identifier(orderByTypeName)), - ]), + t.tsTypeParameterInstantiation( + findManyTypeArgs.map(fn => fn(sel)), + ), ); const retType = (sel: t.TSType) => t.tsTypeAnnotation( @@ -316,31 +324,31 @@ export function generateModelFile( t.identifier('args'), t.identifier('select'), ); - const bodyArgs = [ - t.stringLiteral(typeName), - t.stringLiteral(pluralQueryName), - selectExpr, - t.objectExpression([ - t.objectProperty( + const findManyObjProps = [ + t.objectProperty( + t.identifier('where'), + t.optionalMemberExpression( + t.identifier('args'), t.identifier('where'), - t.optionalMemberExpression( - t.identifier('args'), - t.identifier('where'), - false, - true, - ), - ), - t.objectProperty( - t.identifier('condition'), - t.optionalMemberExpression( - t.identifier('args'), - t.identifier('condition'), - false, - true, - ), + false, + true, ), - t.objectProperty( - t.identifier('orderBy'), + ), + ...(conditionTypeName + ? [ + t.objectProperty( + t.identifier('condition'), + t.optionalMemberExpression( + t.identifier('args'), + t.identifier('condition'), + false, + true, + ), + ), + ] + : []), + t.objectProperty( + t.identifier('orderBy'), t.tsAsExpression( t.optionalMemberExpression( t.identifier('args'), @@ -399,11 +407,18 @@ export function generateModelFile( true, ), ), - ]), + ]; + const bodyArgs = [ + t.stringLiteral(typeName), + t.stringLiteral(pluralQueryName), + selectExpr, + t.objectExpression(findManyObjProps), t.stringLiteral(whereTypeName), t.stringLiteral(orderByTypeName), t.identifier('connectionFieldsMap'), - t.stringLiteral(conditionTypeName), + ...(conditionTypeName + ? [t.stringLiteral(conditionTypeName)] + : []), ]; classBody.push( createClassMethod( @@ -424,14 +439,19 @@ export function generateModelFile( // ── findFirst ────────────────────────────────────────────────────────── { + const findFirstTypeArgs: Array<(sel: t.TSType) => t.TSType> = [ + (sel: t.TSType) => sel, + () => t.tsTypeReference(t.identifier(whereTypeName)), + ...(conditionTypeName + ? [() => t.tsTypeReference(t.identifier(conditionTypeName))] + : []), + ]; const argsType = (sel: t.TSType) => t.tsTypeReference( t.identifier('FindFirstArgs'), - t.tsTypeParameterInstantiation([ - sel, - t.tsTypeReference(t.identifier(whereTypeName)), - t.tsTypeReference(t.identifier(conditionTypeName)), - ]), + t.tsTypeParameterInstantiation( + findFirstTypeArgs.map(fn => fn(sel)), + ), ); const retType = (sel: t.TSType) => t.tsTypeAnnotation( @@ -477,33 +497,40 @@ export function generateModelFile( t.identifier('args'), t.identifier('select'), ); + const findFirstObjProps = [ + t.objectProperty( + t.identifier('where'), + t.optionalMemberExpression( + t.identifier('args'), + t.identifier('where'), + false, + true, + ), + ), + ...(conditionTypeName + ? [ + t.objectProperty( + t.identifier('condition'), + t.optionalMemberExpression( + t.identifier('args'), + t.identifier('condition'), + false, + true, + ), + ), + ] + : []), + ]; const bodyArgs = [ t.stringLiteral(typeName), t.stringLiteral(pluralQueryName), selectExpr, - t.objectExpression([ - t.objectProperty( - t.identifier('where'), - t.optionalMemberExpression( - t.identifier('args'), - t.identifier('where'), - false, - true, - ), - ), - t.objectProperty( - t.identifier('condition'), - t.optionalMemberExpression( - t.identifier('args'), - t.identifier('condition'), - false, - true, - ), - ), - ]), + t.objectExpression(findFirstObjProps), t.stringLiteral(whereTypeName), t.identifier('connectionFieldsMap'), - t.stringLiteral(conditionTypeName), + ...(conditionTypeName + ? [t.stringLiteral(conditionTypeName)] + : []), ]; classBody.push( createClassMethod( @@ -976,6 +1003,7 @@ export function generateModelFile( export function generateAllModelFiles( tables: CleanTable[], useSharedTypes: boolean, + options?: { condition?: boolean }, ): GeneratedModelFile[] { - return tables.map((table) => generateModelFile(table, useSharedTypes)); + return tables.map((table) => generateModelFile(table, useSharedTypes, options)); } diff --git a/graphql/codegen/src/core/codegen/templates/query-builder.ts b/graphql/codegen/src/core/codegen/templates/query-builder.ts index 045f86a3d..05fa28dcd 100644 --- a/graphql/codegen/src/core/codegen/templates/query-builder.ts +++ b/graphql/codegen/src/core/codegen/templates/query-builder.ts @@ -201,7 +201,7 @@ export function buildSelections( // Document Builders // ============================================================================ -export function buildFindManyDocument( +export function buildFindManyDocument( operationName: string, queryField: string, select: TSelect, @@ -320,7 +320,7 @@ export function buildFindManyDocument( return { document: print(document), variables }; } -export function buildFindFirstDocument( +export function buildFindFirstDocument( operationName: string, queryField: string, select: TSelect, diff --git a/graphql/codegen/src/core/codegen/templates/select-types.ts b/graphql/codegen/src/core/codegen/templates/select-types.ts index c27939da0..ffb2f797a 100644 --- a/graphql/codegen/src/core/codegen/templates/select-types.ts +++ b/graphql/codegen/src/core/codegen/templates/select-types.ts @@ -21,7 +21,7 @@ export interface PageInfo { endCursor?: string | null; } -export interface FindManyArgs { +export interface FindManyArgs { select?: TSelect; where?: TWhere; condition?: TCondition; @@ -33,7 +33,7 @@ export interface FindManyArgs { offset?: number; } -export interface FindFirstArgs { +export interface FindFirstArgs { select?: TSelect; where?: TWhere; condition?: TCondition; diff --git a/graphql/codegen/src/types/config.ts b/graphql/codegen/src/types/config.ts index d3a5a90c1..fdd854faf 100644 --- a/graphql/codegen/src/types/config.ts +++ b/graphql/codegen/src/types/config.ts @@ -329,6 +329,14 @@ export interface GraphQLSDKConfigTarget { * @default true */ comments?: boolean; + /** + * Generate condition types and condition arguments on findMany/findFirst. + * PostGraphile's native `condition` argument provides simple equality filtering. + * Set to `true` to include condition types and arguments in generated code. + * Set to `false` to omit them (e.g., when using connection-filter's `filter` argument exclusively). + * @default false + */ + condition?: boolean; }; /** @@ -524,6 +532,7 @@ export const DEFAULT_CONFIG: GraphQLSDKConfigTarget = { codegen: { skipQueryField: true, comments: true, + condition: false, }, orm: false, reactQuery: false, diff --git a/sdk/constructive-cli/src/admin/orm/input-types.ts b/sdk/constructive-cli/src/admin/orm/input-types.ts index 6bc1887db..e6d8e8279 100644 --- a/sdk/constructive-cli/src/admin/orm/input-types.ts +++ b/sdk/constructive-cli/src/admin/orm/input-types.ts @@ -163,6 +163,13 @@ export interface InternetAddressFilter { export interface FullTextFilter { matches?: string; } +export interface VectorFilter { + isNull?: boolean; + equalTo?: number[]; + notEqualTo?: number[]; + distinctFrom?: number[]; + notDistinctFrom?: number[]; +} export interface StringListFilter { isNull?: boolean; equalTo?: string[]; @@ -1403,287 +1410,6 @@ export interface OrgInviteFilter { or?: OrgInviteFilter[]; not?: OrgInviteFilter; } -// ============ Table Condition Types ============ -export interface OrgGetManagersRecordCondition { - userId?: string | null; - depth?: number | null; -} -export interface OrgGetSubordinatesRecordCondition { - userId?: string | null; - depth?: number | null; -} -export interface AppPermissionCondition { - id?: string | null; - name?: string | null; - bitnum?: number | null; - bitstr?: string | null; - description?: string | null; -} -export interface OrgPermissionCondition { - id?: string | null; - name?: string | null; - bitnum?: number | null; - bitstr?: string | null; - description?: string | null; -} -export interface AppLevelRequirementCondition { - id?: string | null; - name?: string | null; - level?: string | null; - description?: string | null; - requiredCount?: number | null; - priority?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgMemberCondition { - id?: string | null; - isAdmin?: boolean | null; - actorId?: string | null; - entityId?: string | null; -} -export interface AppPermissionDefaultCondition { - id?: string | null; - permissions?: string | null; -} -export interface OrgPermissionDefaultCondition { - id?: string | null; - permissions?: string | null; - entityId?: string | null; -} -export interface AppAdminGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppOwnerGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgAdminGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgOwnerGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppLimitDefaultCondition { - id?: string | null; - name?: string | null; - max?: number | null; -} -export interface OrgLimitDefaultCondition { - id?: string | null; - name?: string | null; - max?: number | null; -} -export interface MembershipTypeCondition { - id?: number | null; - name?: string | null; - description?: string | null; - prefix?: string | null; -} -export interface OrgChartEdgeGrantCondition { - id?: string | null; - entityId?: string | null; - childId?: string | null; - parentId?: string | null; - grantorId?: string | null; - isGrant?: boolean | null; - positionTitle?: string | null; - positionLevel?: number | null; - createdAt?: string | null; -} -export interface AppLimitCondition { - id?: string | null; - name?: string | null; - actorId?: string | null; - num?: number | null; - max?: number | null; -} -export interface AppAchievementCondition { - id?: string | null; - actorId?: string | null; - name?: string | null; - count?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppStepCondition { - id?: string | null; - actorId?: string | null; - name?: string | null; - count?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ClaimedInviteCondition { - id?: string | null; - data?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppGrantCondition { - id?: string | null; - permissions?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppMembershipDefaultCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isVerified?: boolean | null; -} -export interface OrgLimitCondition { - id?: string | null; - name?: string | null; - actorId?: string | null; - num?: number | null; - max?: number | null; - entityId?: string | null; -} -export interface OrgClaimedInviteCondition { - id?: string | null; - data?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; -} -export interface OrgGrantCondition { - id?: string | null; - permissions?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgChartEdgeCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; - childId?: string | null; - parentId?: string | null; - positionTitle?: string | null; - positionLevel?: number | null; -} -export interface OrgMembershipDefaultCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - entityId?: string | null; - deleteMemberCascadeGroups?: boolean | null; - createGroupsCascadeMembers?: boolean | null; -} -export interface InviteCondition { - id?: string | null; - email?: unknown | null; - senderId?: string | null; - inviteToken?: string | null; - inviteValid?: boolean | null; - inviteLimit?: number | null; - inviteCount?: number | null; - multiple?: boolean | null; - data?: unknown | null; - expiresAt?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppLevelCondition { - id?: string | null; - name?: string | null; - description?: string | null; - image?: unknown | null; - ownerId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppMembershipCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isBanned?: boolean | null; - isDisabled?: boolean | null; - isVerified?: boolean | null; - isActive?: boolean | null; - isOwner?: boolean | null; - isAdmin?: boolean | null; - permissions?: string | null; - granted?: string | null; - actorId?: string | null; - profileId?: string | null; -} -export interface OrgMembershipCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isBanned?: boolean | null; - isDisabled?: boolean | null; - isActive?: boolean | null; - isOwner?: boolean | null; - isAdmin?: boolean | null; - permissions?: string | null; - granted?: string | null; - actorId?: string | null; - entityId?: string | null; - profileId?: string | null; -} -export interface OrgInviteCondition { - id?: string | null; - email?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - inviteToken?: string | null; - inviteValid?: boolean | null; - inviteLimit?: number | null; - inviteCount?: number | null; - multiple?: boolean | null; - data?: unknown | null; - expiresAt?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; -} // ============ OrderBy Types ============ export type OrgGetManagersRecordsOrderBy = | 'PRIMARY_KEY_ASC' diff --git a/sdk/constructive-cli/src/admin/orm/query-builder.ts b/sdk/constructive-cli/src/admin/orm/query-builder.ts index 67c3992b5..d116a3678 100644 --- a/sdk/constructive-cli/src/admin/orm/query-builder.ts +++ b/sdk/constructive-cli/src/admin/orm/query-builder.ts @@ -189,12 +189,13 @@ export function buildSelections( // Document Builders // ============================================================================ -export function buildFindManyDocument( +export function buildFindManyDocument( operationName: string, queryField: string, select: TSelect, args: { where?: TWhere; + condition?: TCondition; orderBy?: string[]; first?: number; last?: number; @@ -204,7 +205,8 @@ export function buildFindManyDocument( }, filterTypeName: string, orderByTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -214,6 +216,16 @@ export function buildFindManyDocument( const queryArgs: ArgumentNode[] = []; const variables: Record = {}; + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -290,13 +302,14 @@ export function buildFindManyDocument( return { document: print(document), variables }; } -export function buildFindFirstDocument( +export function buildFindFirstDocument( operationName: string, queryField: string, select: TSelect, - args: { where?: TWhere }, + args: { where?: TWhere; condition?: TCondition }, filterTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -313,6 +326,16 @@ export function buildFindFirstDocument( queryArgs, variables ); + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -728,7 +751,7 @@ function buildConnectionSelections(nodeSelections: FieldNode[]): FieldNode[] { interface VariableSpec { varName: string; argName?: string; - typeName: string; + typeName?: string; value: unknown; } @@ -779,7 +802,7 @@ function addVariable( args: ArgumentNode[], variables: Record ): void { - if (spec.value === undefined) return; + if (spec.value === undefined || !spec.typeName) return; definitions.push( t.variableDefinition({ diff --git a/sdk/constructive-cli/src/admin/orm/select-types.ts b/sdk/constructive-cli/src/admin/orm/select-types.ts index 80165efa6..919d1b935 100644 --- a/sdk/constructive-cli/src/admin/orm/select-types.ts +++ b/sdk/constructive-cli/src/admin/orm/select-types.ts @@ -16,9 +16,10 @@ export interface PageInfo { endCursor?: string | null; } -export interface FindManyArgs { +export interface FindManyArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; orderBy?: TOrderBy[]; first?: number; last?: number; @@ -27,9 +28,10 @@ export interface FindManyArgs { offset?: number; } -export interface FindFirstArgs { +export interface FindFirstArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; } export interface CreateArgs { diff --git a/sdk/constructive-cli/src/auth/orm/input-types.ts b/sdk/constructive-cli/src/auth/orm/input-types.ts index 4cc717c63..94ef7c3b0 100644 --- a/sdk/constructive-cli/src/auth/orm/input-types.ts +++ b/sdk/constructive-cli/src/auth/orm/input-types.ts @@ -163,6 +163,13 @@ export interface InternetAddressFilter { export interface FullTextFilter { matches?: string; } +export interface VectorFilter { + isNull?: boolean; + equalTo?: number[]; + notEqualTo?: number[]; + distinctFrom?: number[]; + notDistinctFrom?: number[]; +} export interface StringListFilter { isNull?: boolean; equalTo?: string[]; @@ -525,70 +532,6 @@ export interface UserFilter { or?: UserFilter[]; not?: UserFilter; } -// ============ Table Condition Types ============ -export interface RoleTypeCondition { - id?: number | null; - name?: string | null; -} -export interface CryptoAddressCondition { - id?: string | null; - ownerId?: string | null; - address?: string | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface PhoneNumberCondition { - id?: string | null; - ownerId?: string | null; - cc?: string | null; - number?: string | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ConnectedAccountCondition { - id?: string | null; - ownerId?: string | null; - service?: string | null; - identifier?: string | null; - details?: unknown | null; - isVerified?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AuditLogCondition { - id?: string | null; - event?: string | null; - actorId?: string | null; - origin?: unknown | null; - userAgent?: string | null; - ipAddress?: string | null; - success?: boolean | null; - createdAt?: string | null; -} -export interface EmailCondition { - id?: string | null; - ownerId?: string | null; - email?: unknown | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface UserCondition { - id?: string | null; - username?: string | null; - displayName?: string | null; - profilePicture?: unknown | null; - searchTsv?: string | null; - type?: number | null; - createdAt?: string | null; - updatedAt?: string | null; - searchTsvRank?: number | null; -} // ============ OrderBy Types ============ export type RoleTypeOrderBy = | 'PRIMARY_KEY_ASC' diff --git a/sdk/constructive-cli/src/auth/orm/query-builder.ts b/sdk/constructive-cli/src/auth/orm/query-builder.ts index 67c3992b5..d116a3678 100644 --- a/sdk/constructive-cli/src/auth/orm/query-builder.ts +++ b/sdk/constructive-cli/src/auth/orm/query-builder.ts @@ -189,12 +189,13 @@ export function buildSelections( // Document Builders // ============================================================================ -export function buildFindManyDocument( +export function buildFindManyDocument( operationName: string, queryField: string, select: TSelect, args: { where?: TWhere; + condition?: TCondition; orderBy?: string[]; first?: number; last?: number; @@ -204,7 +205,8 @@ export function buildFindManyDocument( }, filterTypeName: string, orderByTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -214,6 +216,16 @@ export function buildFindManyDocument( const queryArgs: ArgumentNode[] = []; const variables: Record = {}; + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -290,13 +302,14 @@ export function buildFindManyDocument( return { document: print(document), variables }; } -export function buildFindFirstDocument( +export function buildFindFirstDocument( operationName: string, queryField: string, select: TSelect, - args: { where?: TWhere }, + args: { where?: TWhere; condition?: TCondition }, filterTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -313,6 +326,16 @@ export function buildFindFirstDocument( queryArgs, variables ); + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -728,7 +751,7 @@ function buildConnectionSelections(nodeSelections: FieldNode[]): FieldNode[] { interface VariableSpec { varName: string; argName?: string; - typeName: string; + typeName?: string; value: unknown; } @@ -779,7 +802,7 @@ function addVariable( args: ArgumentNode[], variables: Record ): void { - if (spec.value === undefined) return; + if (spec.value === undefined || !spec.typeName) return; definitions.push( t.variableDefinition({ diff --git a/sdk/constructive-cli/src/auth/orm/select-types.ts b/sdk/constructive-cli/src/auth/orm/select-types.ts index 80165efa6..919d1b935 100644 --- a/sdk/constructive-cli/src/auth/orm/select-types.ts +++ b/sdk/constructive-cli/src/auth/orm/select-types.ts @@ -16,9 +16,10 @@ export interface PageInfo { endCursor?: string | null; } -export interface FindManyArgs { +export interface FindManyArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; orderBy?: TOrderBy[]; first?: number; last?: number; @@ -27,9 +28,10 @@ export interface FindManyArgs { offset?: number; } -export interface FindFirstArgs { +export interface FindFirstArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; } export interface CreateArgs { diff --git a/sdk/constructive-cli/src/objects/orm/input-types.ts b/sdk/constructive-cli/src/objects/orm/input-types.ts index d369bf16a..ac3146648 100644 --- a/sdk/constructive-cli/src/objects/orm/input-types.ts +++ b/sdk/constructive-cli/src/objects/orm/input-types.ts @@ -163,6 +163,13 @@ export interface InternetAddressFilter { export interface FullTextFilter { matches?: string; } +export interface VectorFilter { + isNull?: boolean; + equalTo?: number[]; + notEqualTo?: number[]; + distinctFrom?: number[]; + notDistinctFrom?: number[]; +} export interface StringListFilter { isNull?: boolean; equalTo?: string[]; @@ -398,46 +405,6 @@ export interface CommitFilter { or?: CommitFilter[]; not?: CommitFilter; } -// ============ Table Condition Types ============ -export interface GetAllRecordCondition { - path?: string | null; - data?: unknown | null; -} -export interface ObjectCondition { - hashUuid?: string | null; - id?: string | null; - databaseId?: string | null; - kids?: string | null; - ktree?: string | null; - data?: unknown | null; - frzn?: boolean | null; - createdAt?: string | null; -} -export interface RefCondition { - id?: string | null; - name?: string | null; - databaseId?: string | null; - storeId?: string | null; - commitId?: string | null; -} -export interface StoreCondition { - id?: string | null; - name?: string | null; - databaseId?: string | null; - hash?: string | null; - createdAt?: string | null; -} -export interface CommitCondition { - id?: string | null; - message?: string | null; - databaseId?: string | null; - storeId?: string | null; - parentIds?: string | null; - authorId?: string | null; - committerId?: string | null; - treeId?: string | null; - date?: string | null; -} // ============ OrderBy Types ============ export type GetAllRecordsOrderBy = | 'PRIMARY_KEY_ASC' diff --git a/sdk/constructive-cli/src/objects/orm/query-builder.ts b/sdk/constructive-cli/src/objects/orm/query-builder.ts index 67c3992b5..d116a3678 100644 --- a/sdk/constructive-cli/src/objects/orm/query-builder.ts +++ b/sdk/constructive-cli/src/objects/orm/query-builder.ts @@ -189,12 +189,13 @@ export function buildSelections( // Document Builders // ============================================================================ -export function buildFindManyDocument( +export function buildFindManyDocument( operationName: string, queryField: string, select: TSelect, args: { where?: TWhere; + condition?: TCondition; orderBy?: string[]; first?: number; last?: number; @@ -204,7 +205,8 @@ export function buildFindManyDocument( }, filterTypeName: string, orderByTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -214,6 +216,16 @@ export function buildFindManyDocument( const queryArgs: ArgumentNode[] = []; const variables: Record = {}; + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -290,13 +302,14 @@ export function buildFindManyDocument( return { document: print(document), variables }; } -export function buildFindFirstDocument( +export function buildFindFirstDocument( operationName: string, queryField: string, select: TSelect, - args: { where?: TWhere }, + args: { where?: TWhere; condition?: TCondition }, filterTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -313,6 +326,16 @@ export function buildFindFirstDocument( queryArgs, variables ); + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -728,7 +751,7 @@ function buildConnectionSelections(nodeSelections: FieldNode[]): FieldNode[] { interface VariableSpec { varName: string; argName?: string; - typeName: string; + typeName?: string; value: unknown; } @@ -779,7 +802,7 @@ function addVariable( args: ArgumentNode[], variables: Record ): void { - if (spec.value === undefined) return; + if (spec.value === undefined || !spec.typeName) return; definitions.push( t.variableDefinition({ diff --git a/sdk/constructive-cli/src/objects/orm/select-types.ts b/sdk/constructive-cli/src/objects/orm/select-types.ts index 80165efa6..919d1b935 100644 --- a/sdk/constructive-cli/src/objects/orm/select-types.ts +++ b/sdk/constructive-cli/src/objects/orm/select-types.ts @@ -16,9 +16,10 @@ export interface PageInfo { endCursor?: string | null; } -export interface FindManyArgs { +export interface FindManyArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; orderBy?: TOrderBy[]; first?: number; last?: number; @@ -27,9 +28,10 @@ export interface FindManyArgs { offset?: number; } -export interface FindFirstArgs { +export interface FindFirstArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; } export interface CreateArgs { diff --git a/sdk/constructive-cli/src/public/orm/input-types.ts b/sdk/constructive-cli/src/public/orm/input-types.ts index f3a162c68..fb0771ab1 100644 --- a/sdk/constructive-cli/src/public/orm/input-types.ts +++ b/sdk/constructive-cli/src/public/orm/input-types.ts @@ -163,6 +163,13 @@ export interface InternetAddressFilter { export interface FullTextFilter { matches?: string; } +export interface VectorFilter { + isNull?: boolean; + equalTo?: number[]; + notEqualTo?: number[]; + distinctFrom?: number[]; + notDistinctFrom?: number[]; +} export interface StringListFilter { isNull?: boolean; equalTo?: string[]; @@ -6777,1203 +6784,6 @@ export interface HierarchyModuleFilter { or?: HierarchyModuleFilter[]; not?: HierarchyModuleFilter; } -// ============ Table Condition Types ============ -export interface OrgGetManagersRecordCondition { - userId?: string | null; - depth?: number | null; -} -export interface OrgGetSubordinatesRecordCondition { - userId?: string | null; - depth?: number | null; -} -export interface GetAllRecordCondition { - path?: string | null; - data?: unknown | null; -} -export interface AppPermissionCondition { - id?: string | null; - name?: string | null; - bitnum?: number | null; - bitstr?: string | null; - description?: string | null; -} -export interface OrgPermissionCondition { - id?: string | null; - name?: string | null; - bitnum?: number | null; - bitstr?: string | null; - description?: string | null; -} -export interface ObjectCondition { - hashUuid?: string | null; - id?: string | null; - databaseId?: string | null; - kids?: string | null; - ktree?: string | null; - data?: unknown | null; - frzn?: boolean | null; - createdAt?: string | null; -} -export interface AppLevelRequirementCondition { - id?: string | null; - name?: string | null; - level?: string | null; - description?: string | null; - requiredCount?: number | null; - priority?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface DatabaseCondition { - id?: string | null; - ownerId?: string | null; - schemaHash?: string | null; - name?: string | null; - label?: string | null; - hash?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface SchemaCondition { - id?: string | null; - databaseId?: string | null; - name?: string | null; - schemaName?: string | null; - label?: string | null; - description?: string | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - isPublic?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface TableCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - name?: string | null; - label?: string | null; - description?: string | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - useRls?: boolean | null; - timestamps?: boolean | null; - peoplestamps?: boolean | null; - pluralName?: string | null; - singularName?: string | null; - tags?: string | null; - inheritsId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface CheckConstraintCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - type?: string | null; - fieldIds?: string | null; - expr?: unknown | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface FieldCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - label?: string | null; - description?: string | null; - smartTags?: unknown | null; - isRequired?: boolean | null; - defaultValue?: string | null; - defaultValueAst?: unknown | null; - isHidden?: boolean | null; - type?: string | null; - fieldOrder?: number | null; - regexp?: string | null; - chk?: unknown | null; - chkExpr?: unknown | null; - min?: number | null; - max?: number | null; - tags?: string | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ForeignKeyConstraintCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - description?: string | null; - smartTags?: unknown | null; - type?: string | null; - fieldIds?: string | null; - refTableId?: string | null; - refFieldIds?: string | null; - deleteAction?: string | null; - updateAction?: string | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface FullTextSearchCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - fieldId?: string | null; - fieldIds?: string | null; - weights?: string | null; - langs?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface IndexCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - fieldIds?: string | null; - includeFieldIds?: string | null; - accessMethod?: string | null; - indexParams?: unknown | null; - whereClause?: unknown | null; - isUnique?: boolean | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface PolicyCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - granteeName?: string | null; - privilege?: string | null; - permissive?: boolean | null; - disabled?: boolean | null; - policyType?: string | null; - data?: unknown | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface PrimaryKeyConstraintCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - type?: string | null; - fieldIds?: string | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface TableGrantCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - privilege?: string | null; - granteeName?: string | null; - fieldIds?: string | null; - isGrant?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface TriggerCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - event?: string | null; - functionName?: string | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface UniqueConstraintCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - description?: string | null; - smartTags?: unknown | null; - type?: string | null; - fieldIds?: string | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ViewCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - name?: string | null; - tableId?: string | null; - viewType?: string | null; - data?: unknown | null; - filterType?: string | null; - filterData?: unknown | null; - securityInvoker?: boolean | null; - isReadOnly?: boolean | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; -} -export interface ViewTableCondition { - id?: string | null; - viewId?: string | null; - tableId?: string | null; - joinOrder?: number | null; -} -export interface ViewGrantCondition { - id?: string | null; - databaseId?: string | null; - viewId?: string | null; - granteeName?: string | null; - privilege?: string | null; - withGrantOption?: boolean | null; - isGrant?: boolean | null; -} -export interface ViewRuleCondition { - id?: string | null; - databaseId?: string | null; - viewId?: string | null; - name?: string | null; - event?: string | null; - action?: string | null; -} -export interface TableModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - nodeType?: string | null; - useRls?: boolean | null; - data?: unknown | null; - fields?: string | null; -} -export interface TableTemplateModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - ownerTableId?: string | null; - tableName?: string | null; - nodeType?: string | null; - data?: unknown | null; -} -export interface SecureTableProvisionCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - nodeType?: string | null; - useRls?: boolean | null; - nodeData?: unknown | null; - grantRoles?: string | null; - grantPrivileges?: unknown | null; - policyType?: string | null; - policyPrivileges?: string | null; - policyRole?: string | null; - policyPermissive?: boolean | null; - policyName?: string | null; - policyData?: unknown | null; - outFields?: string | null; -} -export interface RelationProvisionCondition { - id?: string | null; - databaseId?: string | null; - relationType?: string | null; - sourceTableId?: string | null; - targetTableId?: string | null; - fieldName?: string | null; - deleteAction?: string | null; - isRequired?: boolean | null; - junctionTableId?: string | null; - junctionTableName?: string | null; - junctionSchemaId?: string | null; - sourceFieldName?: string | null; - targetFieldName?: string | null; - useCompositeKey?: boolean | null; - nodeType?: string | null; - nodeData?: unknown | null; - grantRoles?: string | null; - grantPrivileges?: unknown | null; - policyType?: string | null; - policyPrivileges?: string | null; - policyRole?: string | null; - policyPermissive?: boolean | null; - policyName?: string | null; - policyData?: unknown | null; - outFieldId?: string | null; - outJunctionTableId?: string | null; - outSourceFieldId?: string | null; - outTargetFieldId?: string | null; -} -export interface SchemaGrantCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - granteeName?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface DefaultPrivilegeCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - objectType?: string | null; - privilege?: string | null; - granteeName?: string | null; - isGrant?: boolean | null; -} -export interface ApiSchemaCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - apiId?: string | null; -} -export interface ApiModuleCondition { - id?: string | null; - databaseId?: string | null; - apiId?: string | null; - name?: string | null; - data?: unknown | null; -} -export interface DomainCondition { - id?: string | null; - databaseId?: string | null; - apiId?: string | null; - siteId?: string | null; - subdomain?: unknown | null; - domain?: unknown | null; -} -export interface SiteMetadatumCondition { - id?: string | null; - databaseId?: string | null; - siteId?: string | null; - title?: string | null; - description?: string | null; - ogImage?: unknown | null; -} -export interface SiteModuleCondition { - id?: string | null; - databaseId?: string | null; - siteId?: string | null; - name?: string | null; - data?: unknown | null; -} -export interface SiteThemeCondition { - id?: string | null; - databaseId?: string | null; - siteId?: string | null; - theme?: unknown | null; -} -export interface TriggerFunctionCondition { - id?: string | null; - databaseId?: string | null; - name?: string | null; - code?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ApiCondition { - id?: string | null; - databaseId?: string | null; - name?: string | null; - dbname?: string | null; - roleName?: string | null; - anonRole?: string | null; - isPublic?: boolean | null; -} -export interface SiteCondition { - id?: string | null; - databaseId?: string | null; - title?: string | null; - description?: string | null; - ogImage?: unknown | null; - favicon?: unknown | null; - appleTouchIcon?: unknown | null; - logo?: unknown | null; - dbname?: string | null; -} -export interface AppCondition { - id?: string | null; - databaseId?: string | null; - siteId?: string | null; - name?: string | null; - appImage?: unknown | null; - appStoreLink?: unknown | null; - appStoreId?: string | null; - appIdPrefix?: string | null; - playStoreLink?: unknown | null; -} -export interface ConnectedAccountsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - ownerTableId?: string | null; - tableName?: string | null; -} -export interface CryptoAddressesModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - ownerTableId?: string | null; - tableName?: string | null; - cryptoNetwork?: string | null; -} -export interface CryptoAuthModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - usersTableId?: string | null; - secretsTableId?: string | null; - sessionsTableId?: string | null; - sessionCredentialsTableId?: string | null; - addressesTableId?: string | null; - userField?: string | null; - cryptoNetwork?: string | null; - signInRequestChallenge?: string | null; - signInRecordFailure?: string | null; - signUpWithKey?: string | null; - signInWithChallenge?: string | null; -} -export interface DefaultIdsModuleCondition { - id?: string | null; - databaseId?: string | null; -} -export interface DenormalizedTableFieldCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - fieldId?: string | null; - setIds?: string | null; - refTableId?: string | null; - refFieldId?: string | null; - refIds?: string | null; - useUpdates?: boolean | null; - updateDefaults?: boolean | null; - funcName?: string | null; - funcOrder?: number | null; -} -export interface EmailsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - ownerTableId?: string | null; - tableName?: string | null; -} -export interface EncryptedSecretsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; -} -export interface FieldModuleCondition { - id?: string | null; - databaseId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - fieldId?: string | null; - nodeType?: string | null; - data?: unknown | null; - triggers?: string | null; - functions?: string | null; -} -export interface InvitesModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - emailsTableId?: string | null; - usersTableId?: string | null; - invitesTableId?: string | null; - claimedInvitesTableId?: string | null; - invitesTableName?: string | null; - claimedInvitesTableName?: string | null; - submitInviteCodeFunction?: string | null; - prefix?: string | null; - membershipType?: number | null; - entityTableId?: string | null; -} -export interface LevelsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - stepsTableId?: string | null; - stepsTableName?: string | null; - achievementsTableId?: string | null; - achievementsTableName?: string | null; - levelsTableId?: string | null; - levelsTableName?: string | null; - levelRequirementsTableId?: string | null; - levelRequirementsTableName?: string | null; - completedStep?: string | null; - incompletedStep?: string | null; - tgAchievement?: string | null; - tgAchievementToggle?: string | null; - tgAchievementToggleBoolean?: string | null; - tgAchievementBoolean?: string | null; - upsertAchievement?: string | null; - tgUpdateAchievements?: string | null; - stepsRequired?: string | null; - levelAchieved?: string | null; - prefix?: string | null; - membershipType?: number | null; - entityTableId?: string | null; - actorTableId?: string | null; -} -export interface LimitsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - defaultTableId?: string | null; - defaultTableName?: string | null; - limitIncrementFunction?: string | null; - limitDecrementFunction?: string | null; - limitIncrementTrigger?: string | null; - limitDecrementTrigger?: string | null; - limitUpdateTrigger?: string | null; - limitCheckFunction?: string | null; - prefix?: string | null; - membershipType?: number | null; - entityTableId?: string | null; - actorTableId?: string | null; -} -export interface MembershipTypesModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; -} -export interface MembershipsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - membershipsTableId?: string | null; - membershipsTableName?: string | null; - membersTableId?: string | null; - membersTableName?: string | null; - membershipDefaultsTableId?: string | null; - membershipDefaultsTableName?: string | null; - grantsTableId?: string | null; - grantsTableName?: string | null; - actorTableId?: string | null; - limitsTableId?: string | null; - defaultLimitsTableId?: string | null; - permissionsTableId?: string | null; - defaultPermissionsTableId?: string | null; - sprtTableId?: string | null; - adminGrantsTableId?: string | null; - adminGrantsTableName?: string | null; - ownerGrantsTableId?: string | null; - ownerGrantsTableName?: string | null; - membershipType?: number | null; - entityTableId?: string | null; - entityTableOwnerId?: string | null; - prefix?: string | null; - actorMaskCheck?: string | null; - actorPermCheck?: string | null; - entityIdsByMask?: string | null; - entityIdsByPerm?: string | null; - entityIdsFunction?: string | null; -} -export interface PermissionsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - defaultTableId?: string | null; - defaultTableName?: string | null; - bitlen?: number | null; - membershipType?: number | null; - entityTableId?: string | null; - actorTableId?: string | null; - prefix?: string | null; - getPaddedMask?: string | null; - getMask?: string | null; - getByMask?: string | null; - getMaskByName?: string | null; -} -export interface PhoneNumbersModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - ownerTableId?: string | null; - tableName?: string | null; -} -export interface ProfilesModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - profilePermissionsTableId?: string | null; - profilePermissionsTableName?: string | null; - profileGrantsTableId?: string | null; - profileGrantsTableName?: string | null; - profileDefinitionGrantsTableId?: string | null; - profileDefinitionGrantsTableName?: string | null; - membershipType?: number | null; - entityTableId?: string | null; - actorTableId?: string | null; - permissionsTableId?: string | null; - membershipsTableId?: string | null; - prefix?: string | null; -} -export interface RlsModuleCondition { - id?: string | null; - databaseId?: string | null; - apiId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - sessionCredentialsTableId?: string | null; - sessionsTableId?: string | null; - usersTableId?: string | null; - authenticate?: string | null; - authenticateStrict?: string | null; - currentRole?: string | null; - currentRoleId?: string | null; -} -export interface SecretsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; -} -export interface SessionsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - sessionsTableId?: string | null; - sessionCredentialsTableId?: string | null; - authSettingsTableId?: string | null; - usersTableId?: string | null; - sessionsDefaultExpiration?: string | null; - sessionsTable?: string | null; - sessionCredentialsTable?: string | null; - authSettingsTable?: string | null; -} -export interface UserAuthModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - emailsTableId?: string | null; - usersTableId?: string | null; - secretsTableId?: string | null; - encryptedTableId?: string | null; - sessionsTableId?: string | null; - sessionCredentialsTableId?: string | null; - auditsTableId?: string | null; - auditsTableName?: string | null; - signInFunction?: string | null; - signUpFunction?: string | null; - signOutFunction?: string | null; - setPasswordFunction?: string | null; - resetPasswordFunction?: string | null; - forgotPasswordFunction?: string | null; - sendVerificationEmailFunction?: string | null; - verifyEmailFunction?: string | null; - verifyPasswordFunction?: string | null; - checkPasswordFunction?: string | null; - sendAccountDeletionEmailFunction?: string | null; - deleteAccountFunction?: string | null; - signInOneTimeTokenFunction?: string | null; - oneTimeTokenFunction?: string | null; - extendTokenExpires?: string | null; -} -export interface UsersModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - typeTableId?: string | null; - typeTableName?: string | null; -} -export interface UuidModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - uuidFunction?: string | null; - uuidSeed?: string | null; -} -export interface DatabaseProvisionModuleCondition { - id?: string | null; - databaseName?: string | null; - ownerId?: string | null; - subdomain?: string | null; - domain?: string | null; - modules?: string | null; - options?: unknown | null; - bootstrapUser?: boolean | null; - status?: string | null; - errorMessage?: string | null; - databaseId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - completedAt?: string | null; -} -export interface AppAdminGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppOwnerGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppGrantCondition { - id?: string | null; - permissions?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgMembershipCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isBanned?: boolean | null; - isDisabled?: boolean | null; - isActive?: boolean | null; - isOwner?: boolean | null; - isAdmin?: boolean | null; - permissions?: string | null; - granted?: string | null; - actorId?: string | null; - entityId?: string | null; - profileId?: string | null; -} -export interface OrgMemberCondition { - id?: string | null; - isAdmin?: boolean | null; - actorId?: string | null; - entityId?: string | null; -} -export interface OrgAdminGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgOwnerGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgGrantCondition { - id?: string | null; - permissions?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgChartEdgeCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; - childId?: string | null; - parentId?: string | null; - positionTitle?: string | null; - positionLevel?: number | null; -} -export interface OrgChartEdgeGrantCondition { - id?: string | null; - entityId?: string | null; - childId?: string | null; - parentId?: string | null; - grantorId?: string | null; - isGrant?: boolean | null; - positionTitle?: string | null; - positionLevel?: number | null; - createdAt?: string | null; -} -export interface AppLimitCondition { - id?: string | null; - name?: string | null; - actorId?: string | null; - num?: number | null; - max?: number | null; -} -export interface OrgLimitCondition { - id?: string | null; - name?: string | null; - actorId?: string | null; - num?: number | null; - max?: number | null; - entityId?: string | null; -} -export interface AppStepCondition { - id?: string | null; - actorId?: string | null; - name?: string | null; - count?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppAchievementCondition { - id?: string | null; - actorId?: string | null; - name?: string | null; - count?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface InviteCondition { - id?: string | null; - email?: unknown | null; - senderId?: string | null; - inviteToken?: string | null; - inviteValid?: boolean | null; - inviteLimit?: number | null; - inviteCount?: number | null; - multiple?: boolean | null; - data?: unknown | null; - expiresAt?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ClaimedInviteCondition { - id?: string | null; - data?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgInviteCondition { - id?: string | null; - email?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - inviteToken?: string | null; - inviteValid?: boolean | null; - inviteLimit?: number | null; - inviteCount?: number | null; - multiple?: boolean | null; - data?: unknown | null; - expiresAt?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; -} -export interface OrgClaimedInviteCondition { - id?: string | null; - data?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; -} -export interface RefCondition { - id?: string | null; - name?: string | null; - databaseId?: string | null; - storeId?: string | null; - commitId?: string | null; -} -export interface StoreCondition { - id?: string | null; - name?: string | null; - databaseId?: string | null; - hash?: string | null; - createdAt?: string | null; -} -export interface AppPermissionDefaultCondition { - id?: string | null; - permissions?: string | null; -} -export interface RoleTypeCondition { - id?: number | null; - name?: string | null; -} -export interface OrgPermissionDefaultCondition { - id?: string | null; - permissions?: string | null; - entityId?: string | null; -} -export interface CryptoAddressCondition { - id?: string | null; - ownerId?: string | null; - address?: string | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppLimitDefaultCondition { - id?: string | null; - name?: string | null; - max?: number | null; -} -export interface OrgLimitDefaultCondition { - id?: string | null; - name?: string | null; - max?: number | null; -} -export interface ConnectedAccountCondition { - id?: string | null; - ownerId?: string | null; - service?: string | null; - identifier?: string | null; - details?: unknown | null; - isVerified?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface PhoneNumberCondition { - id?: string | null; - ownerId?: string | null; - cc?: string | null; - number?: string | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface MembershipTypeCondition { - id?: number | null; - name?: string | null; - description?: string | null; - prefix?: string | null; -} -export interface NodeTypeRegistryCondition { - name?: string | null; - slug?: string | null; - category?: string | null; - displayName?: string | null; - description?: string | null; - parameterSchema?: unknown | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppMembershipDefaultCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isVerified?: boolean | null; -} -export interface CommitCondition { - id?: string | null; - message?: string | null; - databaseId?: string | null; - storeId?: string | null; - parentIds?: string | null; - authorId?: string | null; - committerId?: string | null; - treeId?: string | null; - date?: string | null; -} -export interface OrgMembershipDefaultCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - entityId?: string | null; - deleteMemberCascadeGroups?: boolean | null; - createGroupsCascadeMembers?: boolean | null; -} -export interface AuditLogCondition { - id?: string | null; - event?: string | null; - actorId?: string | null; - origin?: unknown | null; - userAgent?: string | null; - ipAddress?: string | null; - success?: boolean | null; - createdAt?: string | null; -} -export interface AppLevelCondition { - id?: string | null; - name?: string | null; - description?: string | null; - image?: unknown | null; - ownerId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface EmailCondition { - id?: string | null; - ownerId?: string | null; - email?: unknown | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface SqlMigrationCondition { - id?: number | null; - name?: string | null; - databaseId?: string | null; - deploy?: string | null; - deps?: string | null; - payload?: unknown | null; - content?: string | null; - revert?: string | null; - verify?: string | null; - createdAt?: string | null; - action?: string | null; - actionId?: string | null; - actorId?: string | null; -} -export interface AstMigrationCondition { - id?: number | null; - databaseId?: string | null; - name?: string | null; - requires?: string | null; - payload?: unknown | null; - deploys?: string | null; - deploy?: unknown | null; - revert?: unknown | null; - verify?: unknown | null; - createdAt?: string | null; - action?: string | null; - actionId?: string | null; - actorId?: string | null; -} -export interface UserCondition { - id?: string | null; - username?: string | null; - displayName?: string | null; - profilePicture?: unknown | null; - searchTsv?: string | null; - type?: number | null; - createdAt?: string | null; - updatedAt?: string | null; - searchTsvRank?: number | null; -} -export interface AppMembershipCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isBanned?: boolean | null; - isDisabled?: boolean | null; - isVerified?: boolean | null; - isActive?: boolean | null; - isOwner?: boolean | null; - isAdmin?: boolean | null; - permissions?: string | null; - granted?: string | null; - actorId?: string | null; - profileId?: string | null; -} -export interface HierarchyModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - chartEdgesTableId?: string | null; - chartEdgesTableName?: string | null; - hierarchySprtTableId?: string | null; - hierarchySprtTableName?: string | null; - chartEdgeGrantsTableId?: string | null; - chartEdgeGrantsTableName?: string | null; - entityTableId?: string | null; - usersTableId?: string | null; - prefix?: string | null; - privateSchemaName?: string | null; - sprtTableName?: string | null; - rebuildHierarchyFunction?: string | null; - getSubordinatesFunction?: string | null; - getManagersFunction?: string | null; - isManagerOfFunction?: string | null; - createdAt?: string | null; -} // ============ OrderBy Types ============ export type OrgGetManagersRecordsOrderBy = | 'PRIMARY_KEY_ASC' diff --git a/sdk/constructive-cli/src/public/orm/query-builder.ts b/sdk/constructive-cli/src/public/orm/query-builder.ts index 67c3992b5..d116a3678 100644 --- a/sdk/constructive-cli/src/public/orm/query-builder.ts +++ b/sdk/constructive-cli/src/public/orm/query-builder.ts @@ -189,12 +189,13 @@ export function buildSelections( // Document Builders // ============================================================================ -export function buildFindManyDocument( +export function buildFindManyDocument( operationName: string, queryField: string, select: TSelect, args: { where?: TWhere; + condition?: TCondition; orderBy?: string[]; first?: number; last?: number; @@ -204,7 +205,8 @@ export function buildFindManyDocument( }, filterTypeName: string, orderByTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -214,6 +216,16 @@ export function buildFindManyDocument( const queryArgs: ArgumentNode[] = []; const variables: Record = {}; + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -290,13 +302,14 @@ export function buildFindManyDocument( return { document: print(document), variables }; } -export function buildFindFirstDocument( +export function buildFindFirstDocument( operationName: string, queryField: string, select: TSelect, - args: { where?: TWhere }, + args: { where?: TWhere; condition?: TCondition }, filterTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -313,6 +326,16 @@ export function buildFindFirstDocument( queryArgs, variables ); + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -728,7 +751,7 @@ function buildConnectionSelections(nodeSelections: FieldNode[]): FieldNode[] { interface VariableSpec { varName: string; argName?: string; - typeName: string; + typeName?: string; value: unknown; } @@ -779,7 +802,7 @@ function addVariable( args: ArgumentNode[], variables: Record ): void { - if (spec.value === undefined) return; + if (spec.value === undefined || !spec.typeName) return; definitions.push( t.variableDefinition({ diff --git a/sdk/constructive-cli/src/public/orm/select-types.ts b/sdk/constructive-cli/src/public/orm/select-types.ts index 80165efa6..919d1b935 100644 --- a/sdk/constructive-cli/src/public/orm/select-types.ts +++ b/sdk/constructive-cli/src/public/orm/select-types.ts @@ -16,9 +16,10 @@ export interface PageInfo { endCursor?: string | null; } -export interface FindManyArgs { +export interface FindManyArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; orderBy?: TOrderBy[]; first?: number; last?: number; @@ -27,9 +28,10 @@ export interface FindManyArgs { offset?: number; } -export interface FindFirstArgs { +export interface FindFirstArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; } export interface CreateArgs { diff --git a/sdk/constructive-sdk/src/admin/orm/input-types.ts b/sdk/constructive-sdk/src/admin/orm/input-types.ts index 6bc1887db..e6d8e8279 100644 --- a/sdk/constructive-sdk/src/admin/orm/input-types.ts +++ b/sdk/constructive-sdk/src/admin/orm/input-types.ts @@ -163,6 +163,13 @@ export interface InternetAddressFilter { export interface FullTextFilter { matches?: string; } +export interface VectorFilter { + isNull?: boolean; + equalTo?: number[]; + notEqualTo?: number[]; + distinctFrom?: number[]; + notDistinctFrom?: number[]; +} export interface StringListFilter { isNull?: boolean; equalTo?: string[]; @@ -1403,287 +1410,6 @@ export interface OrgInviteFilter { or?: OrgInviteFilter[]; not?: OrgInviteFilter; } -// ============ Table Condition Types ============ -export interface OrgGetManagersRecordCondition { - userId?: string | null; - depth?: number | null; -} -export interface OrgGetSubordinatesRecordCondition { - userId?: string | null; - depth?: number | null; -} -export interface AppPermissionCondition { - id?: string | null; - name?: string | null; - bitnum?: number | null; - bitstr?: string | null; - description?: string | null; -} -export interface OrgPermissionCondition { - id?: string | null; - name?: string | null; - bitnum?: number | null; - bitstr?: string | null; - description?: string | null; -} -export interface AppLevelRequirementCondition { - id?: string | null; - name?: string | null; - level?: string | null; - description?: string | null; - requiredCount?: number | null; - priority?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgMemberCondition { - id?: string | null; - isAdmin?: boolean | null; - actorId?: string | null; - entityId?: string | null; -} -export interface AppPermissionDefaultCondition { - id?: string | null; - permissions?: string | null; -} -export interface OrgPermissionDefaultCondition { - id?: string | null; - permissions?: string | null; - entityId?: string | null; -} -export interface AppAdminGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppOwnerGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgAdminGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgOwnerGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppLimitDefaultCondition { - id?: string | null; - name?: string | null; - max?: number | null; -} -export interface OrgLimitDefaultCondition { - id?: string | null; - name?: string | null; - max?: number | null; -} -export interface MembershipTypeCondition { - id?: number | null; - name?: string | null; - description?: string | null; - prefix?: string | null; -} -export interface OrgChartEdgeGrantCondition { - id?: string | null; - entityId?: string | null; - childId?: string | null; - parentId?: string | null; - grantorId?: string | null; - isGrant?: boolean | null; - positionTitle?: string | null; - positionLevel?: number | null; - createdAt?: string | null; -} -export interface AppLimitCondition { - id?: string | null; - name?: string | null; - actorId?: string | null; - num?: number | null; - max?: number | null; -} -export interface AppAchievementCondition { - id?: string | null; - actorId?: string | null; - name?: string | null; - count?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppStepCondition { - id?: string | null; - actorId?: string | null; - name?: string | null; - count?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ClaimedInviteCondition { - id?: string | null; - data?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppGrantCondition { - id?: string | null; - permissions?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppMembershipDefaultCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isVerified?: boolean | null; -} -export interface OrgLimitCondition { - id?: string | null; - name?: string | null; - actorId?: string | null; - num?: number | null; - max?: number | null; - entityId?: string | null; -} -export interface OrgClaimedInviteCondition { - id?: string | null; - data?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; -} -export interface OrgGrantCondition { - id?: string | null; - permissions?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgChartEdgeCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; - childId?: string | null; - parentId?: string | null; - positionTitle?: string | null; - positionLevel?: number | null; -} -export interface OrgMembershipDefaultCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - entityId?: string | null; - deleteMemberCascadeGroups?: boolean | null; - createGroupsCascadeMembers?: boolean | null; -} -export interface InviteCondition { - id?: string | null; - email?: unknown | null; - senderId?: string | null; - inviteToken?: string | null; - inviteValid?: boolean | null; - inviteLimit?: number | null; - inviteCount?: number | null; - multiple?: boolean | null; - data?: unknown | null; - expiresAt?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppLevelCondition { - id?: string | null; - name?: string | null; - description?: string | null; - image?: unknown | null; - ownerId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppMembershipCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isBanned?: boolean | null; - isDisabled?: boolean | null; - isVerified?: boolean | null; - isActive?: boolean | null; - isOwner?: boolean | null; - isAdmin?: boolean | null; - permissions?: string | null; - granted?: string | null; - actorId?: string | null; - profileId?: string | null; -} -export interface OrgMembershipCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isBanned?: boolean | null; - isDisabled?: boolean | null; - isActive?: boolean | null; - isOwner?: boolean | null; - isAdmin?: boolean | null; - permissions?: string | null; - granted?: string | null; - actorId?: string | null; - entityId?: string | null; - profileId?: string | null; -} -export interface OrgInviteCondition { - id?: string | null; - email?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - inviteToken?: string | null; - inviteValid?: boolean | null; - inviteLimit?: number | null; - inviteCount?: number | null; - multiple?: boolean | null; - data?: unknown | null; - expiresAt?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; -} // ============ OrderBy Types ============ export type OrgGetManagersRecordsOrderBy = | 'PRIMARY_KEY_ASC' diff --git a/sdk/constructive-sdk/src/admin/orm/query-builder.ts b/sdk/constructive-sdk/src/admin/orm/query-builder.ts index 67c3992b5..d116a3678 100644 --- a/sdk/constructive-sdk/src/admin/orm/query-builder.ts +++ b/sdk/constructive-sdk/src/admin/orm/query-builder.ts @@ -189,12 +189,13 @@ export function buildSelections( // Document Builders // ============================================================================ -export function buildFindManyDocument( +export function buildFindManyDocument( operationName: string, queryField: string, select: TSelect, args: { where?: TWhere; + condition?: TCondition; orderBy?: string[]; first?: number; last?: number; @@ -204,7 +205,8 @@ export function buildFindManyDocument( }, filterTypeName: string, orderByTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -214,6 +216,16 @@ export function buildFindManyDocument( const queryArgs: ArgumentNode[] = []; const variables: Record = {}; + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -290,13 +302,14 @@ export function buildFindManyDocument( return { document: print(document), variables }; } -export function buildFindFirstDocument( +export function buildFindFirstDocument( operationName: string, queryField: string, select: TSelect, - args: { where?: TWhere }, + args: { where?: TWhere; condition?: TCondition }, filterTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -313,6 +326,16 @@ export function buildFindFirstDocument( queryArgs, variables ); + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -728,7 +751,7 @@ function buildConnectionSelections(nodeSelections: FieldNode[]): FieldNode[] { interface VariableSpec { varName: string; argName?: string; - typeName: string; + typeName?: string; value: unknown; } @@ -779,7 +802,7 @@ function addVariable( args: ArgumentNode[], variables: Record ): void { - if (spec.value === undefined) return; + if (spec.value === undefined || !spec.typeName) return; definitions.push( t.variableDefinition({ diff --git a/sdk/constructive-sdk/src/admin/orm/select-types.ts b/sdk/constructive-sdk/src/admin/orm/select-types.ts index 80165efa6..919d1b935 100644 --- a/sdk/constructive-sdk/src/admin/orm/select-types.ts +++ b/sdk/constructive-sdk/src/admin/orm/select-types.ts @@ -16,9 +16,10 @@ export interface PageInfo { endCursor?: string | null; } -export interface FindManyArgs { +export interface FindManyArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; orderBy?: TOrderBy[]; first?: number; last?: number; @@ -27,9 +28,10 @@ export interface FindManyArgs { offset?: number; } -export interface FindFirstArgs { +export interface FindFirstArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; } export interface CreateArgs { diff --git a/sdk/constructive-sdk/src/auth/orm/input-types.ts b/sdk/constructive-sdk/src/auth/orm/input-types.ts index 4cc717c63..94ef7c3b0 100644 --- a/sdk/constructive-sdk/src/auth/orm/input-types.ts +++ b/sdk/constructive-sdk/src/auth/orm/input-types.ts @@ -163,6 +163,13 @@ export interface InternetAddressFilter { export interface FullTextFilter { matches?: string; } +export interface VectorFilter { + isNull?: boolean; + equalTo?: number[]; + notEqualTo?: number[]; + distinctFrom?: number[]; + notDistinctFrom?: number[]; +} export interface StringListFilter { isNull?: boolean; equalTo?: string[]; @@ -525,70 +532,6 @@ export interface UserFilter { or?: UserFilter[]; not?: UserFilter; } -// ============ Table Condition Types ============ -export interface RoleTypeCondition { - id?: number | null; - name?: string | null; -} -export interface CryptoAddressCondition { - id?: string | null; - ownerId?: string | null; - address?: string | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface PhoneNumberCondition { - id?: string | null; - ownerId?: string | null; - cc?: string | null; - number?: string | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ConnectedAccountCondition { - id?: string | null; - ownerId?: string | null; - service?: string | null; - identifier?: string | null; - details?: unknown | null; - isVerified?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AuditLogCondition { - id?: string | null; - event?: string | null; - actorId?: string | null; - origin?: unknown | null; - userAgent?: string | null; - ipAddress?: string | null; - success?: boolean | null; - createdAt?: string | null; -} -export interface EmailCondition { - id?: string | null; - ownerId?: string | null; - email?: unknown | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface UserCondition { - id?: string | null; - username?: string | null; - displayName?: string | null; - profilePicture?: unknown | null; - searchTsv?: string | null; - type?: number | null; - createdAt?: string | null; - updatedAt?: string | null; - searchTsvRank?: number | null; -} // ============ OrderBy Types ============ export type RoleTypeOrderBy = | 'PRIMARY_KEY_ASC' diff --git a/sdk/constructive-sdk/src/auth/orm/query-builder.ts b/sdk/constructive-sdk/src/auth/orm/query-builder.ts index 67c3992b5..d116a3678 100644 --- a/sdk/constructive-sdk/src/auth/orm/query-builder.ts +++ b/sdk/constructive-sdk/src/auth/orm/query-builder.ts @@ -189,12 +189,13 @@ export function buildSelections( // Document Builders // ============================================================================ -export function buildFindManyDocument( +export function buildFindManyDocument( operationName: string, queryField: string, select: TSelect, args: { where?: TWhere; + condition?: TCondition; orderBy?: string[]; first?: number; last?: number; @@ -204,7 +205,8 @@ export function buildFindManyDocument( }, filterTypeName: string, orderByTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -214,6 +216,16 @@ export function buildFindManyDocument( const queryArgs: ArgumentNode[] = []; const variables: Record = {}; + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -290,13 +302,14 @@ export function buildFindManyDocument( return { document: print(document), variables }; } -export function buildFindFirstDocument( +export function buildFindFirstDocument( operationName: string, queryField: string, select: TSelect, - args: { where?: TWhere }, + args: { where?: TWhere; condition?: TCondition }, filterTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -313,6 +326,16 @@ export function buildFindFirstDocument( queryArgs, variables ); + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -728,7 +751,7 @@ function buildConnectionSelections(nodeSelections: FieldNode[]): FieldNode[] { interface VariableSpec { varName: string; argName?: string; - typeName: string; + typeName?: string; value: unknown; } @@ -779,7 +802,7 @@ function addVariable( args: ArgumentNode[], variables: Record ): void { - if (spec.value === undefined) return; + if (spec.value === undefined || !spec.typeName) return; definitions.push( t.variableDefinition({ diff --git a/sdk/constructive-sdk/src/auth/orm/select-types.ts b/sdk/constructive-sdk/src/auth/orm/select-types.ts index 80165efa6..919d1b935 100644 --- a/sdk/constructive-sdk/src/auth/orm/select-types.ts +++ b/sdk/constructive-sdk/src/auth/orm/select-types.ts @@ -16,9 +16,10 @@ export interface PageInfo { endCursor?: string | null; } -export interface FindManyArgs { +export interface FindManyArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; orderBy?: TOrderBy[]; first?: number; last?: number; @@ -27,9 +28,10 @@ export interface FindManyArgs { offset?: number; } -export interface FindFirstArgs { +export interface FindFirstArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; } export interface CreateArgs { diff --git a/sdk/constructive-sdk/src/objects/orm/input-types.ts b/sdk/constructive-sdk/src/objects/orm/input-types.ts index d369bf16a..ac3146648 100644 --- a/sdk/constructive-sdk/src/objects/orm/input-types.ts +++ b/sdk/constructive-sdk/src/objects/orm/input-types.ts @@ -163,6 +163,13 @@ export interface InternetAddressFilter { export interface FullTextFilter { matches?: string; } +export interface VectorFilter { + isNull?: boolean; + equalTo?: number[]; + notEqualTo?: number[]; + distinctFrom?: number[]; + notDistinctFrom?: number[]; +} export interface StringListFilter { isNull?: boolean; equalTo?: string[]; @@ -398,46 +405,6 @@ export interface CommitFilter { or?: CommitFilter[]; not?: CommitFilter; } -// ============ Table Condition Types ============ -export interface GetAllRecordCondition { - path?: string | null; - data?: unknown | null; -} -export interface ObjectCondition { - hashUuid?: string | null; - id?: string | null; - databaseId?: string | null; - kids?: string | null; - ktree?: string | null; - data?: unknown | null; - frzn?: boolean | null; - createdAt?: string | null; -} -export interface RefCondition { - id?: string | null; - name?: string | null; - databaseId?: string | null; - storeId?: string | null; - commitId?: string | null; -} -export interface StoreCondition { - id?: string | null; - name?: string | null; - databaseId?: string | null; - hash?: string | null; - createdAt?: string | null; -} -export interface CommitCondition { - id?: string | null; - message?: string | null; - databaseId?: string | null; - storeId?: string | null; - parentIds?: string | null; - authorId?: string | null; - committerId?: string | null; - treeId?: string | null; - date?: string | null; -} // ============ OrderBy Types ============ export type GetAllRecordsOrderBy = | 'PRIMARY_KEY_ASC' diff --git a/sdk/constructive-sdk/src/objects/orm/query-builder.ts b/sdk/constructive-sdk/src/objects/orm/query-builder.ts index 67c3992b5..d116a3678 100644 --- a/sdk/constructive-sdk/src/objects/orm/query-builder.ts +++ b/sdk/constructive-sdk/src/objects/orm/query-builder.ts @@ -189,12 +189,13 @@ export function buildSelections( // Document Builders // ============================================================================ -export function buildFindManyDocument( +export function buildFindManyDocument( operationName: string, queryField: string, select: TSelect, args: { where?: TWhere; + condition?: TCondition; orderBy?: string[]; first?: number; last?: number; @@ -204,7 +205,8 @@ export function buildFindManyDocument( }, filterTypeName: string, orderByTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -214,6 +216,16 @@ export function buildFindManyDocument( const queryArgs: ArgumentNode[] = []; const variables: Record = {}; + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -290,13 +302,14 @@ export function buildFindManyDocument( return { document: print(document), variables }; } -export function buildFindFirstDocument( +export function buildFindFirstDocument( operationName: string, queryField: string, select: TSelect, - args: { where?: TWhere }, + args: { where?: TWhere; condition?: TCondition }, filterTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -313,6 +326,16 @@ export function buildFindFirstDocument( queryArgs, variables ); + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -728,7 +751,7 @@ function buildConnectionSelections(nodeSelections: FieldNode[]): FieldNode[] { interface VariableSpec { varName: string; argName?: string; - typeName: string; + typeName?: string; value: unknown; } @@ -779,7 +802,7 @@ function addVariable( args: ArgumentNode[], variables: Record ): void { - if (spec.value === undefined) return; + if (spec.value === undefined || !spec.typeName) return; definitions.push( t.variableDefinition({ diff --git a/sdk/constructive-sdk/src/objects/orm/select-types.ts b/sdk/constructive-sdk/src/objects/orm/select-types.ts index 80165efa6..919d1b935 100644 --- a/sdk/constructive-sdk/src/objects/orm/select-types.ts +++ b/sdk/constructive-sdk/src/objects/orm/select-types.ts @@ -16,9 +16,10 @@ export interface PageInfo { endCursor?: string | null; } -export interface FindManyArgs { +export interface FindManyArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; orderBy?: TOrderBy[]; first?: number; last?: number; @@ -27,9 +28,10 @@ export interface FindManyArgs { offset?: number; } -export interface FindFirstArgs { +export interface FindFirstArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; } export interface CreateArgs { diff --git a/sdk/constructive-sdk/src/public/orm/input-types.ts b/sdk/constructive-sdk/src/public/orm/input-types.ts index f3a162c68..fb0771ab1 100644 --- a/sdk/constructive-sdk/src/public/orm/input-types.ts +++ b/sdk/constructive-sdk/src/public/orm/input-types.ts @@ -163,6 +163,13 @@ export interface InternetAddressFilter { export interface FullTextFilter { matches?: string; } +export interface VectorFilter { + isNull?: boolean; + equalTo?: number[]; + notEqualTo?: number[]; + distinctFrom?: number[]; + notDistinctFrom?: number[]; +} export interface StringListFilter { isNull?: boolean; equalTo?: string[]; @@ -6777,1203 +6784,6 @@ export interface HierarchyModuleFilter { or?: HierarchyModuleFilter[]; not?: HierarchyModuleFilter; } -// ============ Table Condition Types ============ -export interface OrgGetManagersRecordCondition { - userId?: string | null; - depth?: number | null; -} -export interface OrgGetSubordinatesRecordCondition { - userId?: string | null; - depth?: number | null; -} -export interface GetAllRecordCondition { - path?: string | null; - data?: unknown | null; -} -export interface AppPermissionCondition { - id?: string | null; - name?: string | null; - bitnum?: number | null; - bitstr?: string | null; - description?: string | null; -} -export interface OrgPermissionCondition { - id?: string | null; - name?: string | null; - bitnum?: number | null; - bitstr?: string | null; - description?: string | null; -} -export interface ObjectCondition { - hashUuid?: string | null; - id?: string | null; - databaseId?: string | null; - kids?: string | null; - ktree?: string | null; - data?: unknown | null; - frzn?: boolean | null; - createdAt?: string | null; -} -export interface AppLevelRequirementCondition { - id?: string | null; - name?: string | null; - level?: string | null; - description?: string | null; - requiredCount?: number | null; - priority?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface DatabaseCondition { - id?: string | null; - ownerId?: string | null; - schemaHash?: string | null; - name?: string | null; - label?: string | null; - hash?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface SchemaCondition { - id?: string | null; - databaseId?: string | null; - name?: string | null; - schemaName?: string | null; - label?: string | null; - description?: string | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - isPublic?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface TableCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - name?: string | null; - label?: string | null; - description?: string | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - useRls?: boolean | null; - timestamps?: boolean | null; - peoplestamps?: boolean | null; - pluralName?: string | null; - singularName?: string | null; - tags?: string | null; - inheritsId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface CheckConstraintCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - type?: string | null; - fieldIds?: string | null; - expr?: unknown | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface FieldCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - label?: string | null; - description?: string | null; - smartTags?: unknown | null; - isRequired?: boolean | null; - defaultValue?: string | null; - defaultValueAst?: unknown | null; - isHidden?: boolean | null; - type?: string | null; - fieldOrder?: number | null; - regexp?: string | null; - chk?: unknown | null; - chkExpr?: unknown | null; - min?: number | null; - max?: number | null; - tags?: string | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ForeignKeyConstraintCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - description?: string | null; - smartTags?: unknown | null; - type?: string | null; - fieldIds?: string | null; - refTableId?: string | null; - refFieldIds?: string | null; - deleteAction?: string | null; - updateAction?: string | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface FullTextSearchCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - fieldId?: string | null; - fieldIds?: string | null; - weights?: string | null; - langs?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface IndexCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - fieldIds?: string | null; - includeFieldIds?: string | null; - accessMethod?: string | null; - indexParams?: unknown | null; - whereClause?: unknown | null; - isUnique?: boolean | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface PolicyCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - granteeName?: string | null; - privilege?: string | null; - permissive?: boolean | null; - disabled?: boolean | null; - policyType?: string | null; - data?: unknown | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface PrimaryKeyConstraintCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - type?: string | null; - fieldIds?: string | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface TableGrantCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - privilege?: string | null; - granteeName?: string | null; - fieldIds?: string | null; - isGrant?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface TriggerCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - event?: string | null; - functionName?: string | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface UniqueConstraintCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - name?: string | null; - description?: string | null; - smartTags?: unknown | null; - type?: string | null; - fieldIds?: string | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ViewCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - name?: string | null; - tableId?: string | null; - viewType?: string | null; - data?: unknown | null; - filterType?: string | null; - filterData?: unknown | null; - securityInvoker?: boolean | null; - isReadOnly?: boolean | null; - smartTags?: unknown | null; - category?: unknown | null; - module?: string | null; - scope?: number | null; - tags?: string | null; -} -export interface ViewTableCondition { - id?: string | null; - viewId?: string | null; - tableId?: string | null; - joinOrder?: number | null; -} -export interface ViewGrantCondition { - id?: string | null; - databaseId?: string | null; - viewId?: string | null; - granteeName?: string | null; - privilege?: string | null; - withGrantOption?: boolean | null; - isGrant?: boolean | null; -} -export interface ViewRuleCondition { - id?: string | null; - databaseId?: string | null; - viewId?: string | null; - name?: string | null; - event?: string | null; - action?: string | null; -} -export interface TableModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - nodeType?: string | null; - useRls?: boolean | null; - data?: unknown | null; - fields?: string | null; -} -export interface TableTemplateModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - ownerTableId?: string | null; - tableName?: string | null; - nodeType?: string | null; - data?: unknown | null; -} -export interface SecureTableProvisionCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - nodeType?: string | null; - useRls?: boolean | null; - nodeData?: unknown | null; - grantRoles?: string | null; - grantPrivileges?: unknown | null; - policyType?: string | null; - policyPrivileges?: string | null; - policyRole?: string | null; - policyPermissive?: boolean | null; - policyName?: string | null; - policyData?: unknown | null; - outFields?: string | null; -} -export interface RelationProvisionCondition { - id?: string | null; - databaseId?: string | null; - relationType?: string | null; - sourceTableId?: string | null; - targetTableId?: string | null; - fieldName?: string | null; - deleteAction?: string | null; - isRequired?: boolean | null; - junctionTableId?: string | null; - junctionTableName?: string | null; - junctionSchemaId?: string | null; - sourceFieldName?: string | null; - targetFieldName?: string | null; - useCompositeKey?: boolean | null; - nodeType?: string | null; - nodeData?: unknown | null; - grantRoles?: string | null; - grantPrivileges?: unknown | null; - policyType?: string | null; - policyPrivileges?: string | null; - policyRole?: string | null; - policyPermissive?: boolean | null; - policyName?: string | null; - policyData?: unknown | null; - outFieldId?: string | null; - outJunctionTableId?: string | null; - outSourceFieldId?: string | null; - outTargetFieldId?: string | null; -} -export interface SchemaGrantCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - granteeName?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface DefaultPrivilegeCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - objectType?: string | null; - privilege?: string | null; - granteeName?: string | null; - isGrant?: boolean | null; -} -export interface ApiSchemaCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - apiId?: string | null; -} -export interface ApiModuleCondition { - id?: string | null; - databaseId?: string | null; - apiId?: string | null; - name?: string | null; - data?: unknown | null; -} -export interface DomainCondition { - id?: string | null; - databaseId?: string | null; - apiId?: string | null; - siteId?: string | null; - subdomain?: unknown | null; - domain?: unknown | null; -} -export interface SiteMetadatumCondition { - id?: string | null; - databaseId?: string | null; - siteId?: string | null; - title?: string | null; - description?: string | null; - ogImage?: unknown | null; -} -export interface SiteModuleCondition { - id?: string | null; - databaseId?: string | null; - siteId?: string | null; - name?: string | null; - data?: unknown | null; -} -export interface SiteThemeCondition { - id?: string | null; - databaseId?: string | null; - siteId?: string | null; - theme?: unknown | null; -} -export interface TriggerFunctionCondition { - id?: string | null; - databaseId?: string | null; - name?: string | null; - code?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ApiCondition { - id?: string | null; - databaseId?: string | null; - name?: string | null; - dbname?: string | null; - roleName?: string | null; - anonRole?: string | null; - isPublic?: boolean | null; -} -export interface SiteCondition { - id?: string | null; - databaseId?: string | null; - title?: string | null; - description?: string | null; - ogImage?: unknown | null; - favicon?: unknown | null; - appleTouchIcon?: unknown | null; - logo?: unknown | null; - dbname?: string | null; -} -export interface AppCondition { - id?: string | null; - databaseId?: string | null; - siteId?: string | null; - name?: string | null; - appImage?: unknown | null; - appStoreLink?: unknown | null; - appStoreId?: string | null; - appIdPrefix?: string | null; - playStoreLink?: unknown | null; -} -export interface ConnectedAccountsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - ownerTableId?: string | null; - tableName?: string | null; -} -export interface CryptoAddressesModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - ownerTableId?: string | null; - tableName?: string | null; - cryptoNetwork?: string | null; -} -export interface CryptoAuthModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - usersTableId?: string | null; - secretsTableId?: string | null; - sessionsTableId?: string | null; - sessionCredentialsTableId?: string | null; - addressesTableId?: string | null; - userField?: string | null; - cryptoNetwork?: string | null; - signInRequestChallenge?: string | null; - signInRecordFailure?: string | null; - signUpWithKey?: string | null; - signInWithChallenge?: string | null; -} -export interface DefaultIdsModuleCondition { - id?: string | null; - databaseId?: string | null; -} -export interface DenormalizedTableFieldCondition { - id?: string | null; - databaseId?: string | null; - tableId?: string | null; - fieldId?: string | null; - setIds?: string | null; - refTableId?: string | null; - refFieldId?: string | null; - refIds?: string | null; - useUpdates?: boolean | null; - updateDefaults?: boolean | null; - funcName?: string | null; - funcOrder?: number | null; -} -export interface EmailsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - ownerTableId?: string | null; - tableName?: string | null; -} -export interface EncryptedSecretsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; -} -export interface FieldModuleCondition { - id?: string | null; - databaseId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - fieldId?: string | null; - nodeType?: string | null; - data?: unknown | null; - triggers?: string | null; - functions?: string | null; -} -export interface InvitesModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - emailsTableId?: string | null; - usersTableId?: string | null; - invitesTableId?: string | null; - claimedInvitesTableId?: string | null; - invitesTableName?: string | null; - claimedInvitesTableName?: string | null; - submitInviteCodeFunction?: string | null; - prefix?: string | null; - membershipType?: number | null; - entityTableId?: string | null; -} -export interface LevelsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - stepsTableId?: string | null; - stepsTableName?: string | null; - achievementsTableId?: string | null; - achievementsTableName?: string | null; - levelsTableId?: string | null; - levelsTableName?: string | null; - levelRequirementsTableId?: string | null; - levelRequirementsTableName?: string | null; - completedStep?: string | null; - incompletedStep?: string | null; - tgAchievement?: string | null; - tgAchievementToggle?: string | null; - tgAchievementToggleBoolean?: string | null; - tgAchievementBoolean?: string | null; - upsertAchievement?: string | null; - tgUpdateAchievements?: string | null; - stepsRequired?: string | null; - levelAchieved?: string | null; - prefix?: string | null; - membershipType?: number | null; - entityTableId?: string | null; - actorTableId?: string | null; -} -export interface LimitsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - defaultTableId?: string | null; - defaultTableName?: string | null; - limitIncrementFunction?: string | null; - limitDecrementFunction?: string | null; - limitIncrementTrigger?: string | null; - limitDecrementTrigger?: string | null; - limitUpdateTrigger?: string | null; - limitCheckFunction?: string | null; - prefix?: string | null; - membershipType?: number | null; - entityTableId?: string | null; - actorTableId?: string | null; -} -export interface MembershipTypesModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; -} -export interface MembershipsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - membershipsTableId?: string | null; - membershipsTableName?: string | null; - membersTableId?: string | null; - membersTableName?: string | null; - membershipDefaultsTableId?: string | null; - membershipDefaultsTableName?: string | null; - grantsTableId?: string | null; - grantsTableName?: string | null; - actorTableId?: string | null; - limitsTableId?: string | null; - defaultLimitsTableId?: string | null; - permissionsTableId?: string | null; - defaultPermissionsTableId?: string | null; - sprtTableId?: string | null; - adminGrantsTableId?: string | null; - adminGrantsTableName?: string | null; - ownerGrantsTableId?: string | null; - ownerGrantsTableName?: string | null; - membershipType?: number | null; - entityTableId?: string | null; - entityTableOwnerId?: string | null; - prefix?: string | null; - actorMaskCheck?: string | null; - actorPermCheck?: string | null; - entityIdsByMask?: string | null; - entityIdsByPerm?: string | null; - entityIdsFunction?: string | null; -} -export interface PermissionsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - defaultTableId?: string | null; - defaultTableName?: string | null; - bitlen?: number | null; - membershipType?: number | null; - entityTableId?: string | null; - actorTableId?: string | null; - prefix?: string | null; - getPaddedMask?: string | null; - getMask?: string | null; - getByMask?: string | null; - getMaskByName?: string | null; -} -export interface PhoneNumbersModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - ownerTableId?: string | null; - tableName?: string | null; -} -export interface ProfilesModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - profilePermissionsTableId?: string | null; - profilePermissionsTableName?: string | null; - profileGrantsTableId?: string | null; - profileGrantsTableName?: string | null; - profileDefinitionGrantsTableId?: string | null; - profileDefinitionGrantsTableName?: string | null; - membershipType?: number | null; - entityTableId?: string | null; - actorTableId?: string | null; - permissionsTableId?: string | null; - membershipsTableId?: string | null; - prefix?: string | null; -} -export interface RlsModuleCondition { - id?: string | null; - databaseId?: string | null; - apiId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - sessionCredentialsTableId?: string | null; - sessionsTableId?: string | null; - usersTableId?: string | null; - authenticate?: string | null; - authenticateStrict?: string | null; - currentRole?: string | null; - currentRoleId?: string | null; -} -export interface SecretsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; -} -export interface SessionsModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - sessionsTableId?: string | null; - sessionCredentialsTableId?: string | null; - authSettingsTableId?: string | null; - usersTableId?: string | null; - sessionsDefaultExpiration?: string | null; - sessionsTable?: string | null; - sessionCredentialsTable?: string | null; - authSettingsTable?: string | null; -} -export interface UserAuthModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - emailsTableId?: string | null; - usersTableId?: string | null; - secretsTableId?: string | null; - encryptedTableId?: string | null; - sessionsTableId?: string | null; - sessionCredentialsTableId?: string | null; - auditsTableId?: string | null; - auditsTableName?: string | null; - signInFunction?: string | null; - signUpFunction?: string | null; - signOutFunction?: string | null; - setPasswordFunction?: string | null; - resetPasswordFunction?: string | null; - forgotPasswordFunction?: string | null; - sendVerificationEmailFunction?: string | null; - verifyEmailFunction?: string | null; - verifyPasswordFunction?: string | null; - checkPasswordFunction?: string | null; - sendAccountDeletionEmailFunction?: string | null; - deleteAccountFunction?: string | null; - signInOneTimeTokenFunction?: string | null; - oneTimeTokenFunction?: string | null; - extendTokenExpires?: string | null; -} -export interface UsersModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - tableId?: string | null; - tableName?: string | null; - typeTableId?: string | null; - typeTableName?: string | null; -} -export interface UuidModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - uuidFunction?: string | null; - uuidSeed?: string | null; -} -export interface DatabaseProvisionModuleCondition { - id?: string | null; - databaseName?: string | null; - ownerId?: string | null; - subdomain?: string | null; - domain?: string | null; - modules?: string | null; - options?: unknown | null; - bootstrapUser?: boolean | null; - status?: string | null; - errorMessage?: string | null; - databaseId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - completedAt?: string | null; -} -export interface AppAdminGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppOwnerGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppGrantCondition { - id?: string | null; - permissions?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgMembershipCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isBanned?: boolean | null; - isDisabled?: boolean | null; - isActive?: boolean | null; - isOwner?: boolean | null; - isAdmin?: boolean | null; - permissions?: string | null; - granted?: string | null; - actorId?: string | null; - entityId?: string | null; - profileId?: string | null; -} -export interface OrgMemberCondition { - id?: string | null; - isAdmin?: boolean | null; - actorId?: string | null; - entityId?: string | null; -} -export interface OrgAdminGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgOwnerGrantCondition { - id?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgGrantCondition { - id?: string | null; - permissions?: string | null; - isGrant?: boolean | null; - actorId?: string | null; - entityId?: string | null; - grantorId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgChartEdgeCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; - childId?: string | null; - parentId?: string | null; - positionTitle?: string | null; - positionLevel?: number | null; -} -export interface OrgChartEdgeGrantCondition { - id?: string | null; - entityId?: string | null; - childId?: string | null; - parentId?: string | null; - grantorId?: string | null; - isGrant?: boolean | null; - positionTitle?: string | null; - positionLevel?: number | null; - createdAt?: string | null; -} -export interface AppLimitCondition { - id?: string | null; - name?: string | null; - actorId?: string | null; - num?: number | null; - max?: number | null; -} -export interface OrgLimitCondition { - id?: string | null; - name?: string | null; - actorId?: string | null; - num?: number | null; - max?: number | null; - entityId?: string | null; -} -export interface AppStepCondition { - id?: string | null; - actorId?: string | null; - name?: string | null; - count?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppAchievementCondition { - id?: string | null; - actorId?: string | null; - name?: string | null; - count?: number | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface InviteCondition { - id?: string | null; - email?: unknown | null; - senderId?: string | null; - inviteToken?: string | null; - inviteValid?: boolean | null; - inviteLimit?: number | null; - inviteCount?: number | null; - multiple?: boolean | null; - data?: unknown | null; - expiresAt?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface ClaimedInviteCondition { - id?: string | null; - data?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface OrgInviteCondition { - id?: string | null; - email?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - inviteToken?: string | null; - inviteValid?: boolean | null; - inviteLimit?: number | null; - inviteCount?: number | null; - multiple?: boolean | null; - data?: unknown | null; - expiresAt?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; -} -export interface OrgClaimedInviteCondition { - id?: string | null; - data?: unknown | null; - senderId?: string | null; - receiverId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - entityId?: string | null; -} -export interface RefCondition { - id?: string | null; - name?: string | null; - databaseId?: string | null; - storeId?: string | null; - commitId?: string | null; -} -export interface StoreCondition { - id?: string | null; - name?: string | null; - databaseId?: string | null; - hash?: string | null; - createdAt?: string | null; -} -export interface AppPermissionDefaultCondition { - id?: string | null; - permissions?: string | null; -} -export interface RoleTypeCondition { - id?: number | null; - name?: string | null; -} -export interface OrgPermissionDefaultCondition { - id?: string | null; - permissions?: string | null; - entityId?: string | null; -} -export interface CryptoAddressCondition { - id?: string | null; - ownerId?: string | null; - address?: string | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppLimitDefaultCondition { - id?: string | null; - name?: string | null; - max?: number | null; -} -export interface OrgLimitDefaultCondition { - id?: string | null; - name?: string | null; - max?: number | null; -} -export interface ConnectedAccountCondition { - id?: string | null; - ownerId?: string | null; - service?: string | null; - identifier?: string | null; - details?: unknown | null; - isVerified?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface PhoneNumberCondition { - id?: string | null; - ownerId?: string | null; - cc?: string | null; - number?: string | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface MembershipTypeCondition { - id?: number | null; - name?: string | null; - description?: string | null; - prefix?: string | null; -} -export interface NodeTypeRegistryCondition { - name?: string | null; - slug?: string | null; - category?: string | null; - displayName?: string | null; - description?: string | null; - parameterSchema?: unknown | null; - tags?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface AppMembershipDefaultCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isVerified?: boolean | null; -} -export interface CommitCondition { - id?: string | null; - message?: string | null; - databaseId?: string | null; - storeId?: string | null; - parentIds?: string | null; - authorId?: string | null; - committerId?: string | null; - treeId?: string | null; - date?: string | null; -} -export interface OrgMembershipDefaultCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - entityId?: string | null; - deleteMemberCascadeGroups?: boolean | null; - createGroupsCascadeMembers?: boolean | null; -} -export interface AuditLogCondition { - id?: string | null; - event?: string | null; - actorId?: string | null; - origin?: unknown | null; - userAgent?: string | null; - ipAddress?: string | null; - success?: boolean | null; - createdAt?: string | null; -} -export interface AppLevelCondition { - id?: string | null; - name?: string | null; - description?: string | null; - image?: unknown | null; - ownerId?: string | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface EmailCondition { - id?: string | null; - ownerId?: string | null; - email?: unknown | null; - isVerified?: boolean | null; - isPrimary?: boolean | null; - createdAt?: string | null; - updatedAt?: string | null; -} -export interface SqlMigrationCondition { - id?: number | null; - name?: string | null; - databaseId?: string | null; - deploy?: string | null; - deps?: string | null; - payload?: unknown | null; - content?: string | null; - revert?: string | null; - verify?: string | null; - createdAt?: string | null; - action?: string | null; - actionId?: string | null; - actorId?: string | null; -} -export interface AstMigrationCondition { - id?: number | null; - databaseId?: string | null; - name?: string | null; - requires?: string | null; - payload?: unknown | null; - deploys?: string | null; - deploy?: unknown | null; - revert?: unknown | null; - verify?: unknown | null; - createdAt?: string | null; - action?: string | null; - actionId?: string | null; - actorId?: string | null; -} -export interface UserCondition { - id?: string | null; - username?: string | null; - displayName?: string | null; - profilePicture?: unknown | null; - searchTsv?: string | null; - type?: number | null; - createdAt?: string | null; - updatedAt?: string | null; - searchTsvRank?: number | null; -} -export interface AppMembershipCondition { - id?: string | null; - createdAt?: string | null; - updatedAt?: string | null; - createdBy?: string | null; - updatedBy?: string | null; - isApproved?: boolean | null; - isBanned?: boolean | null; - isDisabled?: boolean | null; - isVerified?: boolean | null; - isActive?: boolean | null; - isOwner?: boolean | null; - isAdmin?: boolean | null; - permissions?: string | null; - granted?: string | null; - actorId?: string | null; - profileId?: string | null; -} -export interface HierarchyModuleCondition { - id?: string | null; - databaseId?: string | null; - schemaId?: string | null; - privateSchemaId?: string | null; - chartEdgesTableId?: string | null; - chartEdgesTableName?: string | null; - hierarchySprtTableId?: string | null; - hierarchySprtTableName?: string | null; - chartEdgeGrantsTableId?: string | null; - chartEdgeGrantsTableName?: string | null; - entityTableId?: string | null; - usersTableId?: string | null; - prefix?: string | null; - privateSchemaName?: string | null; - sprtTableName?: string | null; - rebuildHierarchyFunction?: string | null; - getSubordinatesFunction?: string | null; - getManagersFunction?: string | null; - isManagerOfFunction?: string | null; - createdAt?: string | null; -} // ============ OrderBy Types ============ export type OrgGetManagersRecordsOrderBy = | 'PRIMARY_KEY_ASC' diff --git a/sdk/constructive-sdk/src/public/orm/query-builder.ts b/sdk/constructive-sdk/src/public/orm/query-builder.ts index 67c3992b5..d116a3678 100644 --- a/sdk/constructive-sdk/src/public/orm/query-builder.ts +++ b/sdk/constructive-sdk/src/public/orm/query-builder.ts @@ -189,12 +189,13 @@ export function buildSelections( // Document Builders // ============================================================================ -export function buildFindManyDocument( +export function buildFindManyDocument( operationName: string, queryField: string, select: TSelect, args: { where?: TWhere; + condition?: TCondition; orderBy?: string[]; first?: number; last?: number; @@ -204,7 +205,8 @@ export function buildFindManyDocument( }, filterTypeName: string, orderByTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -214,6 +216,16 @@ export function buildFindManyDocument( const queryArgs: ArgumentNode[] = []; const variables: Record = {}; + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -290,13 +302,14 @@ export function buildFindManyDocument( return { document: print(document), variables }; } -export function buildFindFirstDocument( +export function buildFindFirstDocument( operationName: string, queryField: string, select: TSelect, - args: { where?: TWhere }, + args: { where?: TWhere; condition?: TCondition }, filterTypeName: string, - connectionFieldsMap?: Record> + connectionFieldsMap?: Record>, + conditionTypeName?: string ): { document: string; variables: Record } { const selections = select ? buildSelections(select as Record, connectionFieldsMap, operationName) @@ -313,6 +326,16 @@ export function buildFindFirstDocument( queryArgs, variables ); + addVariable( + { + varName: 'condition', + typeName: conditionTypeName, + value: args.condition, + }, + variableDefinitions, + queryArgs, + variables + ); addVariable( { varName: 'where', @@ -728,7 +751,7 @@ function buildConnectionSelections(nodeSelections: FieldNode[]): FieldNode[] { interface VariableSpec { varName: string; argName?: string; - typeName: string; + typeName?: string; value: unknown; } @@ -779,7 +802,7 @@ function addVariable( args: ArgumentNode[], variables: Record ): void { - if (spec.value === undefined) return; + if (spec.value === undefined || !spec.typeName) return; definitions.push( t.variableDefinition({ diff --git a/sdk/constructive-sdk/src/public/orm/select-types.ts b/sdk/constructive-sdk/src/public/orm/select-types.ts index 80165efa6..919d1b935 100644 --- a/sdk/constructive-sdk/src/public/orm/select-types.ts +++ b/sdk/constructive-sdk/src/public/orm/select-types.ts @@ -16,9 +16,10 @@ export interface PageInfo { endCursor?: string | null; } -export interface FindManyArgs { +export interface FindManyArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; orderBy?: TOrderBy[]; first?: number; last?: number; @@ -27,9 +28,10 @@ export interface FindManyArgs { offset?: number; } -export interface FindFirstArgs { +export interface FindFirstArgs { select?: TSelect; where?: TWhere; + condition?: TCondition; } export interface CreateArgs {