mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-18 10:31:15 +00:00
refactor(core): Move initial files to @n8n/db (#14953)
This commit is contained in:
@@ -5,17 +5,13 @@ import type {
|
||||
ICredentialDataDecryptedObject,
|
||||
INodeCredentialTestRequest,
|
||||
IPersonalizationSurveyAnswersV4,
|
||||
IUser,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import type { CredentialsEntity } from '@/databases/entities/credentials-entity';
|
||||
import type { Project } from '@/databases/entities/project';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import type { Variables } from '@/databases/entities/variables';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import type { WorkflowHistory } from '@/databases/entities/workflow-history';
|
||||
import type { ScopesField } from '@/services/role.service';
|
||||
import type { SlimProject } from '@/types-db';
|
||||
import type { ListQuery } from '@/types-db';
|
||||
|
||||
export type APIRequest<
|
||||
RouteParams = {},
|
||||
@@ -50,80 +46,6 @@ export type AuthenticatedRequest<
|
||||
// list query
|
||||
// ----------------------------------
|
||||
|
||||
export namespace ListQuery {
|
||||
export type Request = AuthenticatedRequest<{}, {}, {}, Params> & {
|
||||
listQueryOptions?: Options;
|
||||
};
|
||||
|
||||
export type Params = {
|
||||
filter?: string;
|
||||
skip?: string;
|
||||
take?: string;
|
||||
select?: string;
|
||||
sortBy?: string;
|
||||
};
|
||||
|
||||
export type Options = {
|
||||
filter?: Record<string, unknown>;
|
||||
select?: Record<string, true>;
|
||||
skip?: number;
|
||||
take?: number;
|
||||
sortBy?: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Slim workflow returned from a list query operation.
|
||||
*/
|
||||
export namespace Workflow {
|
||||
type OptionalBaseFields = 'name' | 'active' | 'versionId' | 'createdAt' | 'updatedAt' | 'tags';
|
||||
|
||||
type BaseFields = Pick<WorkflowEntity, 'id'> &
|
||||
Partial<Pick<WorkflowEntity, OptionalBaseFields>>;
|
||||
|
||||
type SharedField = Partial<Pick<WorkflowEntity, 'shared'>>;
|
||||
|
||||
type SortingField = 'createdAt' | 'updatedAt' | 'name';
|
||||
|
||||
export type SortOrder = `${SortingField}:asc` | `${SortingField}:desc`;
|
||||
|
||||
type OwnedByField = { ownedBy: SlimUser | null; homeProject: SlimProject | null };
|
||||
|
||||
export type Plain = BaseFields;
|
||||
|
||||
export type WithSharing = BaseFields & SharedField;
|
||||
|
||||
export type WithOwnership = BaseFields & OwnedByField;
|
||||
|
||||
type SharedWithField = { sharedWith: SlimUser[]; sharedWithProjects: SlimProject[] };
|
||||
|
||||
export type WithOwnedByAndSharedWith = BaseFields &
|
||||
OwnedByField &
|
||||
SharedWithField &
|
||||
SharedField;
|
||||
|
||||
export type WithScopes = BaseFields & ScopesField & SharedField;
|
||||
}
|
||||
|
||||
export namespace Credentials {
|
||||
type OwnedByField = { homeProject: SlimProject | null };
|
||||
|
||||
type SharedField = Partial<Pick<CredentialsEntity, 'shared'>>;
|
||||
|
||||
type SharedWithField = { sharedWithProjects: SlimProject[] };
|
||||
|
||||
export type WithSharing = CredentialsEntity & SharedField;
|
||||
|
||||
export type WithOwnedByAndSharedWith = CredentialsEntity &
|
||||
OwnedByField &
|
||||
SharedWithField &
|
||||
SharedField;
|
||||
|
||||
export type WithScopes = CredentialsEntity & ScopesField & SharedField;
|
||||
}
|
||||
}
|
||||
|
||||
type SlimUser = Pick<IUser, 'id' | 'email' | 'firstName' | 'lastName'>;
|
||||
|
||||
export function hasSharing(
|
||||
workflows: ListQuery.Workflow.Plain[] | ListQuery.Workflow.WithSharing[],
|
||||
): workflows is ListQuery.Workflow.WithSharing[] {
|
||||
|
||||
Reference in New Issue
Block a user