2021-12-11 22:18:48 +05:30
|
|
|
import capitalize from 'lodash/capitalize';
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
export const packageTags = () => [
|
|
|
|
{ id: 'gid://gitlab/Packages::Tag/87', name: 'bananas_9', __typename: 'PackageTag' },
|
|
|
|
{ id: 'gid://gitlab/Packages::Tag/86', name: 'bananas_8', __typename: 'PackageTag' },
|
|
|
|
{ id: 'gid://gitlab/Packages::Tag/85', name: 'bananas_7', __typename: 'PackageTag' },
|
|
|
|
];
|
|
|
|
|
|
|
|
export const packagePipelines = (extend) => [
|
|
|
|
{
|
|
|
|
commitPath: '/namespace14/project14/-/commit/b83d6e391c22777fca1ed3012fce84f633d7fed0',
|
|
|
|
createdAt: '2020-08-17T14:23:32Z',
|
|
|
|
id: 'gid://gitlab/Ci::Pipeline/36',
|
|
|
|
path: '/namespace14/project14/-/pipelines/36',
|
|
|
|
name: 'project14',
|
|
|
|
ref: 'master',
|
|
|
|
sha: 'b83d6e391c22777fca1ed3012fce84f633d7fed0',
|
|
|
|
project: {
|
2022-01-26 12:08:38 +05:30
|
|
|
id: '1',
|
2021-10-27 15:23:28 +05:30
|
|
|
name: 'project14',
|
|
|
|
webUrl: 'http://gdk.test:3000/namespace14/project14',
|
|
|
|
__typename: 'Project',
|
|
|
|
},
|
|
|
|
user: {
|
2022-01-26 12:08:38 +05:30
|
|
|
id: 'user-1',
|
2021-10-27 15:23:28 +05:30
|
|
|
name: 'Administrator',
|
|
|
|
},
|
|
|
|
...extend,
|
|
|
|
__typename: 'Pipeline',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export const packageFiles = () => [
|
|
|
|
{
|
|
|
|
id: 'gid://gitlab/Packages::PackageFile/118',
|
|
|
|
fileMd5: 'fileMd5',
|
|
|
|
fileName: 'foo-1.0.1.tgz',
|
|
|
|
fileSha1: 'be93151dc23ac34a82752444556fe79b32c7a1ad',
|
|
|
|
fileSha256: 'fileSha256',
|
|
|
|
size: '409600',
|
|
|
|
createdAt: '2020-08-17T14:23:32Z',
|
|
|
|
downloadPath: 'downloadPath',
|
|
|
|
__typename: 'PackageFile',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'gid://gitlab/Packages::PackageFile/119',
|
|
|
|
fileMd5: null,
|
|
|
|
fileName: 'foo-1.0.2.tgz',
|
|
|
|
fileSha1: 'be93151dc23ac34a82752444556fe79b32c7a1ss',
|
|
|
|
fileSha256: null,
|
|
|
|
size: '409600',
|
|
|
|
createdAt: '2020-08-17T14:23:32Z',
|
|
|
|
downloadPath: 'downloadPath',
|
|
|
|
__typename: 'PackageFile',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export const dependencyLinks = () => [
|
|
|
|
{
|
|
|
|
dependencyType: 'DEPENDENCIES',
|
|
|
|
id: 'gid://gitlab/Packages::DependencyLink/77',
|
|
|
|
__typename: 'PackageDependencyLink',
|
|
|
|
dependency: {
|
|
|
|
id: 'gid://gitlab/Packages::Dependency/3',
|
|
|
|
name: 'Ninject.Extensions.Factory',
|
|
|
|
versionPattern: '3.3.2',
|
|
|
|
__typename: 'PackageDependency',
|
|
|
|
},
|
|
|
|
metadata: {
|
|
|
|
id: 'gid://gitlab/Packages::Nuget::DependencyLinkMetadatum/77',
|
|
|
|
targetFramework: '.NETCoreApp3.1',
|
|
|
|
__typename: 'NugetDependencyLinkMetadata',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
dependencyType: 'DEPENDENCIES',
|
|
|
|
id: 'gid://gitlab/Packages::DependencyLink/78',
|
|
|
|
__typename: 'PackageDependencyLink',
|
|
|
|
dependency: {
|
|
|
|
id: 'gid://gitlab/Packages::Dependency/4',
|
|
|
|
name: 'Ninject.Extensions.Factory',
|
|
|
|
versionPattern: '3.3.2',
|
|
|
|
__typename: 'PackageDependency',
|
|
|
|
},
|
|
|
|
metadata: {
|
|
|
|
id: 'gid://gitlab/Packages::Nuget::DependencyLinkMetadatum/78',
|
|
|
|
targetFramework: '.NETCoreApp3.1',
|
|
|
|
__typename: 'NugetDependencyLinkMetadata',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
2021-11-18 22:05:49 +05:30
|
|
|
export const packageProject = () => ({
|
2022-01-26 12:08:38 +05:30
|
|
|
id: '1',
|
2021-11-18 22:05:49 +05:30
|
|
|
fullPath: 'gitlab-org/gitlab-test',
|
|
|
|
webUrl: 'http://gdk.test:3000/gitlab-org/gitlab-test',
|
|
|
|
__typename: 'Project',
|
|
|
|
});
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
export const packageVersions = () => [
|
|
|
|
{
|
|
|
|
createdAt: '2021-08-10T09:33:54Z',
|
|
|
|
id: 'gid://gitlab/Packages::Package/243',
|
|
|
|
name: '@gitlab-org/package-15',
|
|
|
|
status: 'DEFAULT',
|
|
|
|
tags: { nodes: packageTags() },
|
|
|
|
version: '1.0.1',
|
|
|
|
__typename: 'Package',
|
|
|
|
},
|
|
|
|
{
|
|
|
|
createdAt: '2021-08-10T09:33:54Z',
|
|
|
|
id: 'gid://gitlab/Packages::Package/244',
|
|
|
|
name: '@gitlab-org/package-15',
|
|
|
|
status: 'DEFAULT',
|
|
|
|
tags: { nodes: packageTags() },
|
|
|
|
version: '1.0.2',
|
|
|
|
__typename: 'Package',
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
export const packageData = (extend) => ({
|
2022-04-04 11:22:00 +05:30
|
|
|
__typename: 'Package',
|
2021-10-27 15:23:28 +05:30
|
|
|
id: 'gid://gitlab/Packages::Package/111',
|
2022-03-02 08:16:31 +05:30
|
|
|
canDestroy: true,
|
2021-10-27 15:23:28 +05:30
|
|
|
name: '@gitlab-org/package-15',
|
|
|
|
packageType: 'NPM',
|
|
|
|
version: '1.0.0',
|
|
|
|
createdAt: '2020-08-17T14:23:32Z',
|
|
|
|
updatedAt: '2020-08-17T14:23:32Z',
|
|
|
|
status: 'DEFAULT',
|
2022-03-02 08:16:31 +05:30
|
|
|
mavenUrl: 'http://gdk.test:3000/api/v4/projects/1/packages/maven',
|
|
|
|
npmUrl: 'http://gdk.test:3000/api/v4/projects/1/packages/npm',
|
|
|
|
nugetUrl: 'http://gdk.test:3000/api/v4/projects/1/packages/nuget/index.json',
|
|
|
|
composerConfigRepositoryUrl: 'gdk.test/22',
|
|
|
|
composerUrl: 'http://gdk.test:3000/api/v4/group/22/-/packages/composer/packages.json',
|
|
|
|
conanUrl: 'http://gdk.test:3000/api/v4/projects/1/packages/conan',
|
|
|
|
pypiUrl:
|
|
|
|
'http://__token__:<your_personal_token>@gdk.test:3000/api/v4/projects/1/packages/pypi/simple',
|
|
|
|
pypiSetupUrl: 'http://gdk.test:3000/api/v4/projects/1/packages/pypi',
|
2021-10-27 15:23:28 +05:30
|
|
|
...extend,
|
|
|
|
});
|
|
|
|
|
|
|
|
export const conanMetadata = () => ({
|
2022-01-26 12:08:38 +05:30
|
|
|
id: 'conan-1',
|
2021-10-27 15:23:28 +05:30
|
|
|
packageChannel: 'stable',
|
|
|
|
packageUsername: 'gitlab-org+gitlab-test',
|
|
|
|
recipe: 'package-8/1.0.0@gitlab-org+gitlab-test/stable',
|
|
|
|
recipePath: 'package-8/1.0.0/gitlab-org+gitlab-test/stable',
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
const conanMetadataQuery = () => ({ ...conanMetadata(), __typename: 'ConanMetadata' });
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
export const composerMetadata = () => ({
|
|
|
|
targetSha: 'b83d6e391c22777fca1ed3012fce84f633d7fed0',
|
|
|
|
composerJson: {
|
|
|
|
license: 'MIT',
|
|
|
|
version: '1.0.0',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
const composerMetadataQuery = () => ({
|
|
|
|
...composerMetadata(),
|
|
|
|
__typename: 'ComposerMetadata',
|
|
|
|
});
|
|
|
|
|
2021-11-11 11:23:49 +05:30
|
|
|
export const pypiMetadata = () => ({
|
2022-07-23 23:45:48 +05:30
|
|
|
id: 'pypi-1',
|
2021-10-27 15:23:28 +05:30
|
|
|
requiredPython: '1.0.0',
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
const pypiMetadataQuery = () => ({ ...pypiMetadata(), __typename: 'PypiMetadata' });
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
export const mavenMetadata = () => ({
|
2022-07-23 23:45:48 +05:30
|
|
|
id: 'maven-1',
|
2021-10-27 15:23:28 +05:30
|
|
|
appName: 'appName',
|
|
|
|
appGroup: 'appGroup',
|
|
|
|
appVersion: 'appVersion',
|
|
|
|
path: 'path',
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
const mavenMetadataQuery = () => ({ ...mavenMetadata(), __typename: 'MavenMetadata' });
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
export const nugetMetadata = () => ({
|
2022-07-23 23:45:48 +05:30
|
|
|
id: 'nuget-1',
|
2021-10-27 15:23:28 +05:30
|
|
|
iconUrl: 'iconUrl',
|
|
|
|
licenseUrl: 'licenseUrl',
|
|
|
|
projectUrl: 'projectUrl',
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
const nugetMetadataQuery = () => ({ ...nugetMetadata(), __typename: 'NugetMetadata' });
|
|
|
|
|
|
|
|
const packageTypeMetadataQueryMapping = {
|
|
|
|
CONAN: conanMetadataQuery,
|
|
|
|
COMPOSER: composerMetadataQuery,
|
|
|
|
PYPI: pypiMetadataQuery,
|
|
|
|
MAVEN: mavenMetadataQuery,
|
|
|
|
NUGET: nugetMetadataQuery,
|
|
|
|
};
|
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
export const pagination = (extend) => ({
|
|
|
|
endCursor: 'eyJpZCI6IjIwNSIsIm5hbWUiOiJteS9jb21wYW55L2FwcC9teS1hcHAifQ',
|
|
|
|
hasNextPage: true,
|
|
|
|
hasPreviousPage: true,
|
|
|
|
startCursor: 'eyJpZCI6IjI0NyIsIm5hbWUiOiJ2ZXJzaW9uX3Rlc3QxIn0',
|
|
|
|
__typename: 'PageInfo',
|
|
|
|
...extend,
|
|
|
|
});
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
export const packageDetailsQuery = (extendPackage) => ({
|
|
|
|
data: {
|
|
|
|
package: {
|
|
|
|
...packageData(),
|
|
|
|
metadata: {
|
|
|
|
...conanMetadata(),
|
|
|
|
...composerMetadata(),
|
2021-11-11 11:23:49 +05:30
|
|
|
...pypiMetadata(),
|
2021-10-27 15:23:28 +05:30
|
|
|
...mavenMetadata(),
|
|
|
|
...nugetMetadata(),
|
|
|
|
},
|
|
|
|
project: {
|
2022-01-26 12:08:38 +05:30
|
|
|
id: '1',
|
2021-10-27 15:23:28 +05:30
|
|
|
path: 'projectPath',
|
2022-03-02 08:16:31 +05:30
|
|
|
name: 'gitlab-test',
|
2021-10-27 15:23:28 +05:30
|
|
|
},
|
|
|
|
tags: {
|
|
|
|
nodes: packageTags(),
|
|
|
|
__typename: 'PackageTagConnection',
|
|
|
|
},
|
|
|
|
pipelines: {
|
|
|
|
nodes: packagePipelines(),
|
|
|
|
__typename: 'PipelineConnection',
|
|
|
|
},
|
|
|
|
packageFiles: {
|
|
|
|
nodes: packageFiles(),
|
|
|
|
__typename: 'PackageFileConnection',
|
|
|
|
},
|
|
|
|
versions: {
|
|
|
|
nodes: packageVersions(),
|
|
|
|
__typename: 'PackageConnection',
|
|
|
|
},
|
|
|
|
dependencyLinks: {
|
|
|
|
nodes: dependencyLinks(),
|
|
|
|
},
|
|
|
|
__typename: 'PackageDetailsType',
|
|
|
|
...extendPackage,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
export const packagePipelinesQuery = (pipelines = packagePipelines()) => ({
|
|
|
|
data: {
|
|
|
|
package: {
|
|
|
|
id: 'gid://gitlab/Packages::Package/111',
|
|
|
|
pipelines: {
|
|
|
|
nodes: pipelines,
|
|
|
|
__typename: 'PipelineConnection',
|
|
|
|
},
|
|
|
|
__typename: 'PackageDetailsType',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
export const emptyPackageDetailsQuery = () => ({
|
|
|
|
data: {
|
|
|
|
package: {
|
|
|
|
__typename: 'PackageDetailsType',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2022-07-23 23:45:48 +05:30
|
|
|
export const packageMetadataQuery = (packageType) => {
|
|
|
|
return {
|
|
|
|
data: {
|
|
|
|
package: {
|
|
|
|
id: 'gid://gitlab/Packages::Package/111',
|
|
|
|
packageType,
|
|
|
|
metadata: {
|
|
|
|
...(packageTypeMetadataQueryMapping[packageType]?.() ?? {}),
|
|
|
|
},
|
|
|
|
__typename: 'PackageDetailsType',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
export const packageDestroyMutation = () => ({
|
|
|
|
data: {
|
|
|
|
destroyPackage: {
|
|
|
|
errors: [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
export const packageDestroyMutationError = () => ({
|
|
|
|
data: {
|
|
|
|
destroyPackage: null,
|
|
|
|
},
|
|
|
|
errors: [
|
|
|
|
{
|
|
|
|
message:
|
|
|
|
"The resource that you are attempting to access does not exist or you don't have permission to perform this action",
|
|
|
|
locations: [
|
|
|
|
{
|
|
|
|
line: 2,
|
|
|
|
column: 3,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
path: ['destroyPackage'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
|
|
|
|
export const packageDestroyFileMutation = () => ({
|
|
|
|
data: {
|
|
|
|
destroyPackageFile: {
|
|
|
|
errors: [],
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
export const packageDestroyFileMutationError = () => ({
|
|
|
|
data: {
|
|
|
|
destroyPackageFile: null,
|
|
|
|
},
|
|
|
|
errors: [
|
|
|
|
{
|
|
|
|
message:
|
|
|
|
"The resource that you are attempting to access does not exist or you don't have permission to perform this action",
|
|
|
|
locations: [
|
|
|
|
{
|
|
|
|
line: 2,
|
|
|
|
column: 3,
|
|
|
|
},
|
|
|
|
],
|
|
|
|
path: ['destroyPackageFile'],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
2021-11-18 22:05:49 +05:30
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
export const packagesListQuery = ({ type = 'group', extend = {}, extendPagination = {} } = {}) => ({
|
2021-11-18 22:05:49 +05:30
|
|
|
data: {
|
|
|
|
[type]: {
|
2022-01-26 12:08:38 +05:30
|
|
|
id: '1',
|
2021-11-18 22:05:49 +05:30
|
|
|
packages: {
|
|
|
|
count: 2,
|
|
|
|
nodes: [
|
|
|
|
{
|
|
|
|
...packageData(),
|
|
|
|
project: packageProject(),
|
|
|
|
tags: { nodes: packageTags() },
|
|
|
|
pipelines: {
|
|
|
|
nodes: packagePipelines(),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
...packageData(),
|
|
|
|
project: packageProject(),
|
|
|
|
tags: { nodes: [] },
|
|
|
|
pipelines: { nodes: [] },
|
|
|
|
},
|
|
|
|
],
|
2021-12-11 22:18:48 +05:30
|
|
|
pageInfo: pagination(extendPagination),
|
2021-11-18 22:05:49 +05:30
|
|
|
__typename: 'PackageConnection',
|
|
|
|
},
|
2021-12-11 22:18:48 +05:30
|
|
|
...extend,
|
|
|
|
__typename: capitalize(type),
|
2021-11-18 22:05:49 +05:30
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|