@commercetools-frontend-extensions/operations 0.0.0-canary-20251209161906
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +61 -0
- package/README.md +178 -0
- package/babel.config.js +6 -0
- package/dist/commercetools-frontend-extensions-operations.cjs.d.ts +2 -0
- package/dist/commercetools-frontend-extensions-operations.cjs.dev.js +3273 -0
- package/dist/commercetools-frontend-extensions-operations.cjs.js +7 -0
- package/dist/commercetools-frontend-extensions-operations.cjs.prod.js +3265 -0
- package/dist/commercetools-frontend-extensions-operations.esm.js +3074 -0
- package/dist/declarations/src/@api/export-operations.d.ts +5 -0
- package/dist/declarations/src/@api/fetcher.d.ts +17 -0
- package/dist/declarations/src/@api/file-import-jobs.d.ts +7 -0
- package/dist/declarations/src/@api/file-upload.d.ts +3 -0
- package/dist/declarations/src/@api/import-containers.d.ts +35 -0
- package/dist/declarations/src/@api/import-operations.d.ts +6 -0
- package/dist/declarations/src/@api/index.d.ts +9 -0
- package/dist/declarations/src/@api/process-file.d.ts +3 -0
- package/dist/declarations/src/@api/test-fixtures.d.ts +279 -0
- package/dist/declarations/src/@api/urls.d.ts +74 -0
- package/dist/declarations/src/@components/file-drop-area/active-drag-drop-area.d.ts +10 -0
- package/dist/declarations/src/@components/file-drop-area/disabled-drop-area.d.ts +5 -0
- package/dist/declarations/src/@components/file-drop-area/drop-area-wrapper.d.ts +11 -0
- package/dist/declarations/src/@components/file-drop-area/enabled-drop-area.d.ts +7 -0
- package/dist/declarations/src/@components/file-drop-area/file-drop-area.d.ts +14 -0
- package/dist/declarations/src/@components/file-drop-area/file-dropped-area.d.ts +6 -0
- package/dist/declarations/src/@components/file-drop-area/index.d.ts +7 -0
- package/dist/declarations/src/@components/file-drop-area/styles.d.ts +9 -0
- package/dist/declarations/src/@components/icons/file-icon.d.ts +2 -0
- package/dist/declarations/src/@components/icons/index.d.ts +2 -0
- package/dist/declarations/src/@components/icons/lock-icon.d.ts +2 -0
- package/dist/declarations/src/@components/index.d.ts +6 -0
- package/dist/declarations/src/@components/info-box/index.d.ts +1 -0
- package/dist/declarations/src/@components/info-box/info-box.d.ts +7 -0
- package/dist/declarations/src/@components/upload-separator/index.d.ts +1 -0
- package/dist/declarations/src/@components/upload-separator/upload-separator.d.ts +12 -0
- package/dist/declarations/src/@components/upload-settings/index.d.ts +1 -0
- package/dist/declarations/src/@components/upload-settings/upload-settings.d.ts +11 -0
- package/dist/declarations/src/@components/uploading-modal/index.d.ts +1 -0
- package/dist/declarations/src/@components/uploading-modal/uploading-modal.d.ts +13 -0
- package/dist/declarations/src/@constants/delimiters.d.ts +8 -0
- package/dist/declarations/src/@constants/file-import-job.d.ts +1 -0
- package/dist/declarations/src/@constants/import-limits.d.ts +6 -0
- package/dist/declarations/src/@constants/import-tags.d.ts +7 -0
- package/dist/declarations/src/@constants/index.d.ts +5 -0
- package/dist/declarations/src/@constants/resource-links.d.ts +10 -0
- package/dist/declarations/src/@errors/http-error.d.ts +6 -0
- package/dist/declarations/src/@errors/index.d.ts +9 -0
- package/dist/declarations/src/@errors/invalid-response-error.d.ts +3 -0
- package/dist/declarations/src/@errors/no-resources-to-export-error.d.ts +3 -0
- package/dist/declarations/src/@errors/polling-aborted-error.d.ts +3 -0
- package/dist/declarations/src/@errors/project-key-not-available-error.d.ts +3 -0
- package/dist/declarations/src/@errors/query-predicate-error.d.ts +4 -0
- package/dist/declarations/src/@errors/unexpected-column-error.d.ts +3 -0
- package/dist/declarations/src/@errors/unexpected-operation-state-error.d.ts +4 -0
- package/dist/declarations/src/@errors/unexpected-resource-type-error.d.ts +3 -0
- package/dist/declarations/src/@hooks/index.d.ts +8 -0
- package/dist/declarations/src/@hooks/use-fetch-export-operations.d.ts +15 -0
- package/dist/declarations/src/@hooks/use-fetch-file-import-job.d.ts +17 -0
- package/dist/declarations/src/@hooks/use-fetch-import-container-details.d.ts +15 -0
- package/dist/declarations/src/@hooks/use-fetch-import-operations.d.ts +16 -0
- package/dist/declarations/src/@hooks/use-fetch-import-summaries.d.ts +20 -0
- package/dist/declarations/src/@hooks/use-file-import-job-upload.d.ts +18 -0
- package/dist/declarations/src/@hooks/use-file-upload.d.ts +28 -0
- package/dist/declarations/src/@hooks/use-import-container-upload.d.ts +19 -0
- package/dist/declarations/src/@types/api.d.ts +13 -0
- package/dist/declarations/src/@types/basic-error-data-type.d.ts +5 -0
- package/dist/declarations/src/@types/export-operation.d.ts +97 -0
- package/dist/declarations/src/@types/file-import-job.d.ts +99 -0
- package/dist/declarations/src/@types/file-upload-result.d.ts +21 -0
- package/dist/declarations/src/@types/file-upload.d.ts +63 -0
- package/dist/declarations/src/@types/import-container.d.ts +53 -0
- package/dist/declarations/src/@types/import-operation.d.ts +13 -0
- package/dist/declarations/src/@types/import-states.d.ts +9 -0
- package/dist/declarations/src/@types/import-summary.d.ts +15 -0
- package/dist/declarations/src/@types/index.d.ts +11 -0
- package/dist/declarations/src/@types/shared.d.ts +7 -0
- package/dist/declarations/src/@utils/error-mapping.d.ts +19 -0
- package/dist/declarations/src/@utils/file-import-job-helpers.d.ts +12 -0
- package/dist/declarations/src/@utils/file-upload.d.ts +54 -0
- package/dist/declarations/src/@utils/form.d.ts +1 -0
- package/dist/declarations/src/@utils/format.d.ts +5 -0
- package/dist/declarations/src/@utils/import-container.d.ts +8 -0
- package/dist/declarations/src/@utils/index.d.ts +8 -0
- package/dist/declarations/src/@utils/poll-job-until-validated.d.ts +11 -0
- package/dist/declarations/src/@utils/url.d.ts +6 -0
- package/dist/declarations/src/index.d.ts +26 -0
- package/index.js +1 -0
- package/jest.test.config.js +11 -0
- package/package.json +62 -0
- package/src/@api/export-operations.ts +26 -0
- package/src/@api/fetcher.spec.ts +51 -0
- package/src/@api/fetcher.ts +137 -0
- package/src/@api/file-import-jobs.ts +217 -0
- package/src/@api/file-upload.spec.ts +85 -0
- package/src/@api/file-upload.ts +46 -0
- package/src/@api/import-containers.ts +256 -0
- package/src/@api/import-operations.ts +33 -0
- package/src/@api/index.ts +9 -0
- package/src/@api/process-file.spec.ts +74 -0
- package/src/@api/process-file.ts +53 -0
- package/src/@api/test-fixtures.ts +894 -0
- package/src/@api/urls.ts +194 -0
- package/src/@components/file-drop-area/active-drag-drop-area.tsx +33 -0
- package/src/@components/file-drop-area/disabled-drop-area.tsx +17 -0
- package/src/@components/file-drop-area/drop-area-wrapper.tsx +38 -0
- package/src/@components/file-drop-area/enabled-drop-area.tsx +27 -0
- package/src/@components/file-drop-area/file-drop-area.tsx +74 -0
- package/src/@components/file-drop-area/file-dropped-area.tsx +29 -0
- package/src/@components/file-drop-area/index.ts +7 -0
- package/src/@components/file-drop-area/styles.ts +67 -0
- package/src/@components/icons/file-icon.tsx +30 -0
- package/src/@components/icons/index.ts +2 -0
- package/src/@components/icons/lock-icon.tsx +34 -0
- package/src/@components/index.ts +6 -0
- package/src/@components/info-box/index.ts +1 -0
- package/src/@components/info-box/info-box.tsx +23 -0
- package/src/@components/upload-separator/index.ts +1 -0
- package/src/@components/upload-separator/upload-separator.tsx +61 -0
- package/src/@components/upload-settings/index.ts +1 -0
- package/src/@components/upload-settings/upload-settings.tsx +36 -0
- package/src/@components/uploading-modal/index.ts +1 -0
- package/src/@components/uploading-modal/uploading-modal.tsx +66 -0
- package/src/@constants/delimiters.ts +14 -0
- package/src/@constants/file-import-job.ts +1 -0
- package/src/@constants/import-limits.ts +13 -0
- package/src/@constants/import-tags.ts +9 -0
- package/src/@constants/index.ts +5 -0
- package/src/@constants/resource-links.ts +61 -0
- package/src/@errors/http-error.ts +17 -0
- package/src/@errors/index.ts +9 -0
- package/src/@errors/invalid-response-error.ts +6 -0
- package/src/@errors/no-resources-to-export-error.ts +6 -0
- package/src/@errors/polling-aborted-error.ts +6 -0
- package/src/@errors/project-key-not-available-error.ts +6 -0
- package/src/@errors/query-predicate-error.ts +10 -0
- package/src/@errors/unexpected-column-error.ts +6 -0
- package/src/@errors/unexpected-operation-state-error.ts +8 -0
- package/src/@errors/unexpected-resource-type-error.ts +6 -0
- package/src/@hooks/index.ts +8 -0
- package/src/@hooks/use-fetch-export-operations.ts +34 -0
- package/src/@hooks/use-fetch-file-import-job.spec.ts +131 -0
- package/src/@hooks/use-fetch-file-import-job.ts +38 -0
- package/src/@hooks/use-fetch-import-container-details.ts +31 -0
- package/src/@hooks/use-fetch-import-operations.ts +42 -0
- package/src/@hooks/use-fetch-import-summaries.ts +47 -0
- package/src/@hooks/use-fetch.spec.ts +68 -0
- package/src/@hooks/use-fetch.ts +76 -0
- package/src/@hooks/use-file-import-job-upload.spec.ts +273 -0
- package/src/@hooks/use-file-import-job-upload.ts +101 -0
- package/src/@hooks/use-file-upload.ts +223 -0
- package/src/@hooks/use-import-container-upload.spec.ts +297 -0
- package/src/@hooks/use-import-container-upload.ts +130 -0
- package/src/@types/api.ts +14 -0
- package/src/@types/basic-error-data-type.ts +5 -0
- package/src/@types/export-operation.ts +147 -0
- package/src/@types/file-import-job.ts +165 -0
- package/src/@types/file-upload-result.ts +23 -0
- package/src/@types/file-upload.ts +81 -0
- package/src/@types/import-container.ts +104 -0
- package/src/@types/import-operation.ts +31 -0
- package/src/@types/import-states.ts +9 -0
- package/src/@types/import-summary.ts +22 -0
- package/src/@types/index.ts +11 -0
- package/src/@types/shared.ts +52 -0
- package/src/@utils/error-mapping.spec.ts +126 -0
- package/src/@utils/error-mapping.ts +40 -0
- package/src/@utils/file-import-job-helpers.spec.ts +147 -0
- package/src/@utils/file-import-job-helpers.ts +47 -0
- package/src/@utils/file-upload.spec.ts +151 -0
- package/src/@utils/file-upload.ts +189 -0
- package/src/@utils/form.ts +20 -0
- package/src/@utils/format.spec.ts +62 -0
- package/src/@utils/format.ts +53 -0
- package/src/@utils/import-container.spec.ts +26 -0
- package/src/@utils/import-container.ts +34 -0
- package/src/@utils/index.ts +8 -0
- package/src/@utils/poll-job-until-validated.ts +76 -0
- package/src/@utils/url.spec.ts +75 -0
- package/src/@utils/url.ts +18 -0
- package/src/index.ts +27 -0
- package/tsconfig.json +9 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ResourceTypeId } from '@commercetools/importapi-sdk';
|
|
2
|
+
/**
|
|
3
|
+
* CommerceTools API documentation base URL
|
|
4
|
+
*/
|
|
5
|
+
export declare const CT_API_DOCS_URL = "https://docs.commercetools.com/api/";
|
|
6
|
+
/**
|
|
7
|
+
* Template download links for each resource type
|
|
8
|
+
*/
|
|
9
|
+
export declare const RESOURCE_TYPE_TEMPLATE_DOWNLOAD_LINKS: Record<ResourceTypeId, string>;
|
|
10
|
+
export declare const RESOURCE_TYPE_DOCUMENTATION_LINKS: Record<ResourceTypeId, string>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from "./http-error.js";
|
|
2
|
+
export * from "./invalid-response-error.js";
|
|
3
|
+
export * from "./no-resources-to-export-error.js";
|
|
4
|
+
export * from "./polling-aborted-error.js";
|
|
5
|
+
export * from "./project-key-not-available-error.js";
|
|
6
|
+
export * from "./query-predicate-error.js";
|
|
7
|
+
export * from "./unexpected-column-error.js";
|
|
8
|
+
export * from "./unexpected-operation-state-error.js";
|
|
9
|
+
export * from "./unexpected-resource-type-error.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./use-fetch-export-operations.js";
|
|
2
|
+
export * from "./use-fetch-file-import-job.js";
|
|
3
|
+
export * from "./use-fetch-import-container-details.js";
|
|
4
|
+
export * from "./use-fetch-import-operations.js";
|
|
5
|
+
export * from "./use-fetch-import-summaries.js";
|
|
6
|
+
export * from "./use-file-import-job-upload.js";
|
|
7
|
+
export * from "./use-file-upload.js";
|
|
8
|
+
export * from "./use-import-container-upload.js";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { PaginatedExportOperationResponse, ExportOperationQueryParams } from "../@types/index.js";
|
|
2
|
+
type UseFetchExportOperationsConfig = {
|
|
3
|
+
projectKey: string;
|
|
4
|
+
queryParams: ExportOperationQueryParams;
|
|
5
|
+
pollingInterval?: number;
|
|
6
|
+
shouldContinuePolling?: (data: PaginatedExportOperationResponse) => boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const useFetchExportOperations: ({ projectKey, queryParams, pollingInterval, shouldContinuePolling, }: UseFetchExportOperationsConfig) => {
|
|
9
|
+
data: PaginatedExportOperationResponse | null;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
refetch: () => void;
|
|
13
|
+
lastFetchTime: Date;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { FileImportJob } from "../@types/index.js";
|
|
2
|
+
type UseFetchFileImportJobConfig = {
|
|
3
|
+
projectKey: string;
|
|
4
|
+
resourceType: string;
|
|
5
|
+
importContainerKey: string;
|
|
6
|
+
jobId: string;
|
|
7
|
+
pollingInterval?: number;
|
|
8
|
+
shouldContinuePolling?: (data: FileImportJob) => boolean;
|
|
9
|
+
};
|
|
10
|
+
export declare const useFetchFileImportJob: ({ projectKey, importContainerKey, jobId, pollingInterval, shouldContinuePolling, }: UseFetchFileImportJobConfig) => {
|
|
11
|
+
data: FileImportJob | null;
|
|
12
|
+
error: Error | null;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
refetch: () => void;
|
|
15
|
+
lastFetchTime: Date;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type ImportContainerDetails } from "../@types/index.js";
|
|
2
|
+
type UseFetchImportContainerDetailsConfig = {
|
|
3
|
+
projectKey: string;
|
|
4
|
+
importContainerKey: string;
|
|
5
|
+
pollingInterval?: number;
|
|
6
|
+
shouldContinuePolling?: (data: ImportContainerDetails) => boolean;
|
|
7
|
+
};
|
|
8
|
+
export declare const useFetchImportContainerDetails: ({ projectKey, importContainerKey, pollingInterval, shouldContinuePolling, }: UseFetchImportContainerDetailsConfig) => {
|
|
9
|
+
data: ImportContainerDetails | null;
|
|
10
|
+
error: Error | null;
|
|
11
|
+
isLoading: boolean;
|
|
12
|
+
refetch: () => void;
|
|
13
|
+
lastFetchTime: Date;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ExtendedImportOperationPagedResponse, ImportOperationQueryParams } from "../@types/index.js";
|
|
2
|
+
type UseFetchImportOperationsConfig = {
|
|
3
|
+
projectKey: string;
|
|
4
|
+
importContainerKey: string;
|
|
5
|
+
queryParams: ImportOperationQueryParams;
|
|
6
|
+
pollingInterval?: number;
|
|
7
|
+
shouldContinuePolling?: (data: ExtendedImportOperationPagedResponse) => boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const useFetchImportOperations: ({ projectKey, importContainerKey, queryParams, pollingInterval, shouldContinuePolling, }: UseFetchImportOperationsConfig) => {
|
|
10
|
+
data: ExtendedImportOperationPagedResponse | null;
|
|
11
|
+
error: Error | null;
|
|
12
|
+
isLoading: boolean;
|
|
13
|
+
refetch: () => void;
|
|
14
|
+
lastFetchTime: Date;
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ImportContainerQueryParams, ImportContainerDetails } from "../@types/index.js";
|
|
2
|
+
export type ImportSummariesResult = {
|
|
3
|
+
results: ImportContainerDetails[];
|
|
4
|
+
count: number;
|
|
5
|
+
total: number;
|
|
6
|
+
};
|
|
7
|
+
type UseFetchImportSummariesConfig = {
|
|
8
|
+
projectKey: string;
|
|
9
|
+
queryParams: ImportContainerQueryParams;
|
|
10
|
+
pollingInterval?: number;
|
|
11
|
+
shouldContinuePolling?: (data: ImportSummariesResult) => boolean;
|
|
12
|
+
};
|
|
13
|
+
export declare const useFetchImportSummaries: ({ projectKey, queryParams, pollingInterval, shouldContinuePolling, }: UseFetchImportSummariesConfig) => {
|
|
14
|
+
data: ImportSummariesResult | null;
|
|
15
|
+
error: Error | null;
|
|
16
|
+
isLoading: boolean;
|
|
17
|
+
refetch: () => void;
|
|
18
|
+
lastFetchTime: Date;
|
|
19
|
+
};
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ResourceTypeId } from '@commercetools/importapi-sdk';
|
|
2
|
+
import type { ExtendedImportContainerDraft } from "../@types/index.js";
|
|
3
|
+
export type UseFileImportJobUploadConfig = {
|
|
4
|
+
file: File;
|
|
5
|
+
resourceType: ResourceTypeId;
|
|
6
|
+
settings?: ExtendedImportContainerDraft['settings'];
|
|
7
|
+
onSuccess: (jobId: string, importContainerKey: string) => void;
|
|
8
|
+
onError?: (error: unknown) => void;
|
|
9
|
+
onProgress?: (progress: number) => void;
|
|
10
|
+
abortSignal?: AbortSignal;
|
|
11
|
+
};
|
|
12
|
+
export declare const useFileImportJobUpload: ({ projectKey, }: {
|
|
13
|
+
projectKey: string;
|
|
14
|
+
}) => {
|
|
15
|
+
upload: (config: UseFileImportJobUploadConfig) => Promise<void>;
|
|
16
|
+
isUploading: boolean;
|
|
17
|
+
progress: number;
|
|
18
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ResourceTypeId } from '@commercetools/importapi-sdk';
|
|
2
|
+
import type { ExtendedImportContainerDraft, FileUploadResult, FileImportJob } from "../@types/index.js";
|
|
3
|
+
export type ValidationProgress = {
|
|
4
|
+
processed: number;
|
|
5
|
+
isValidating: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type FileUploadConfig = {
|
|
8
|
+
file: File;
|
|
9
|
+
resourceType: ResourceTypeId;
|
|
10
|
+
settings?: ExtendedImportContainerDraft['settings'];
|
|
11
|
+
onSuccess: (result: FileUploadResult) => void;
|
|
12
|
+
onError?: (error: unknown) => void;
|
|
13
|
+
onProgress?: (progress: number) => void;
|
|
14
|
+
onValidationProgress?: (job: FileImportJob) => void;
|
|
15
|
+
abortSignal?: AbortSignal;
|
|
16
|
+
};
|
|
17
|
+
export type FileUploadOptions = {
|
|
18
|
+
projectKey: string;
|
|
19
|
+
useJobBasedFlow?: boolean;
|
|
20
|
+
pollingInterval?: number;
|
|
21
|
+
maxPollingAttempts?: number;
|
|
22
|
+
};
|
|
23
|
+
export declare const useFileUpload: ({ projectKey, useJobBasedFlow, pollingInterval, maxPollingAttempts, }: FileUploadOptions) => {
|
|
24
|
+
upload: (config: FileUploadConfig) => Promise<void>;
|
|
25
|
+
isUploading: boolean;
|
|
26
|
+
progress: number;
|
|
27
|
+
validationProgress: ValidationProgress;
|
|
28
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ResourceTypeId } from '@commercetools/importapi-sdk';
|
|
2
|
+
import type { FileUploadResponse, ExtendedImportContainerDraft } from "../@types/index.js";
|
|
3
|
+
export type UseImportContainerUploadConfig = {
|
|
4
|
+
file: File;
|
|
5
|
+
resourceType: ResourceTypeId;
|
|
6
|
+
settings?: ExtendedImportContainerDraft['settings'];
|
|
7
|
+
onSuccess: (response: FileUploadResponse, importContainerKey: string) => void;
|
|
8
|
+
onError?: (error: unknown) => void;
|
|
9
|
+
onProgress?: (progress: number) => void;
|
|
10
|
+
abortSignal?: AbortSignal;
|
|
11
|
+
};
|
|
12
|
+
export declare const useImportContainerUpload: ({ projectKey, }: {
|
|
13
|
+
projectKey: string;
|
|
14
|
+
}) => {
|
|
15
|
+
upload: ({ file, resourceType, settings, onSuccess, onError, onProgress, abortSignal, }: UseImportContainerUploadConfig) => Promise<XMLHttpRequest | undefined>;
|
|
16
|
+
abort: () => void;
|
|
17
|
+
isUploading: boolean;
|
|
18
|
+
progress: number;
|
|
19
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type METHOD = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
2
|
+
export type ApiConfig = {
|
|
3
|
+
headers?: Record<string, string | null>;
|
|
4
|
+
method?: METHOD;
|
|
5
|
+
proxy?: string;
|
|
6
|
+
abortSignal?: AbortSignal;
|
|
7
|
+
};
|
|
8
|
+
export type Fetcher = {
|
|
9
|
+
url: string;
|
|
10
|
+
payload?: BodyInit;
|
|
11
|
+
config?: ApiConfig;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ResourceTypeId } from '@commercetools/importapi-sdk';
|
|
2
|
+
export type ExportOperationState = 'processing' | 'completed' | 'failed' | 'queued';
|
|
3
|
+
export type ResourceType = ResourceTypeId;
|
|
4
|
+
export type FileFormat = 'json' | 'csv';
|
|
5
|
+
export type Separator = {
|
|
6
|
+
columns?: string;
|
|
7
|
+
arrayValues?: string;
|
|
8
|
+
decimal?: string;
|
|
9
|
+
};
|
|
10
|
+
export type ExportOperation = {
|
|
11
|
+
id: string;
|
|
12
|
+
fileName: string;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
resourceType: ResourceType;
|
|
15
|
+
state: ExportOperationState;
|
|
16
|
+
completedPercentage: number;
|
|
17
|
+
resourceCount: number;
|
|
18
|
+
fileFormat: FileFormat;
|
|
19
|
+
fields: string[];
|
|
20
|
+
locales: string[];
|
|
21
|
+
query?: string;
|
|
22
|
+
filters?: {
|
|
23
|
+
filters: string[];
|
|
24
|
+
fullText?: {
|
|
25
|
+
text: string;
|
|
26
|
+
locale: string;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
fillRows?: boolean;
|
|
30
|
+
excelCompatible?: boolean;
|
|
31
|
+
dryRun?: boolean;
|
|
32
|
+
separator?: Separator;
|
|
33
|
+
};
|
|
34
|
+
export interface PaginatedExportOperationResponse {
|
|
35
|
+
results: ExportOperation[];
|
|
36
|
+
limit: number;
|
|
37
|
+
offset: number;
|
|
38
|
+
total: number;
|
|
39
|
+
count: number;
|
|
40
|
+
}
|
|
41
|
+
export type DownloadFile = {
|
|
42
|
+
uri: string;
|
|
43
|
+
};
|
|
44
|
+
export type ExportOperationQueryParams = {
|
|
45
|
+
limit: number;
|
|
46
|
+
offset: number;
|
|
47
|
+
};
|
|
48
|
+
export declare function assertPaginatedExportOperationResponse(maybePaginatedExportOperationResponseOrExportOperationsResponse: unknown): asserts maybePaginatedExportOperationResponseOrExportOperationsResponse is PaginatedExportOperationResponse;
|
|
49
|
+
export declare function assertExportOperationsDownloadFileResponse(maybeExportOperationDownloadFileResponse: unknown): asserts maybeExportOperationDownloadFileResponse is DownloadFile;
|
|
50
|
+
export type QueryFilter = {
|
|
51
|
+
query?: Record<string, unknown>;
|
|
52
|
+
};
|
|
53
|
+
export type SearchFilter = {
|
|
54
|
+
filters?: string[];
|
|
55
|
+
fullText?: {
|
|
56
|
+
text: string;
|
|
57
|
+
locale: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export interface ExportApiRequest {
|
|
61
|
+
projectKey: string;
|
|
62
|
+
resourceType: string;
|
|
63
|
+
fileName: string;
|
|
64
|
+
fileFormat: string;
|
|
65
|
+
fields: string[];
|
|
66
|
+
locales?: string[];
|
|
67
|
+
filters?: QueryFilter | SearchFilter;
|
|
68
|
+
where?: string;
|
|
69
|
+
fullText?: {
|
|
70
|
+
text: string;
|
|
71
|
+
locale: string;
|
|
72
|
+
};
|
|
73
|
+
fillRows?: boolean;
|
|
74
|
+
excelCompatible?: boolean;
|
|
75
|
+
separator?: Separator;
|
|
76
|
+
}
|
|
77
|
+
export interface ExportApiSuccessResponse {
|
|
78
|
+
id: string;
|
|
79
|
+
state: string;
|
|
80
|
+
resourceType: string;
|
|
81
|
+
resourceCount: number;
|
|
82
|
+
createdAt: string;
|
|
83
|
+
}
|
|
84
|
+
export interface ExportApiErrorResponse {
|
|
85
|
+
statusCode: number;
|
|
86
|
+
error: string;
|
|
87
|
+
errors: ValidationError[];
|
|
88
|
+
message: string;
|
|
89
|
+
}
|
|
90
|
+
export type ValidationErrorCode = 'DuplicateFields' | 'NotSupportedField' | 'FieldDefinitionNotFound' | 'AttributeDefinitionNotFound' | 'LocalizedFieldWithoutLocale' | 'IncompleteField' | 'AttributeLevelMismatch';
|
|
91
|
+
export type ValidationError = {
|
|
92
|
+
code: ValidationErrorCode;
|
|
93
|
+
message: string;
|
|
94
|
+
field?: string;
|
|
95
|
+
requestedLevel?: string;
|
|
96
|
+
actualLevel?: string;
|
|
97
|
+
};
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export type FileImportJobState = 'queued' | 'processing' | 'validated' | 'initialising' | 'ready' | 'rejected';
|
|
2
|
+
export interface FileImportJobSummary {
|
|
3
|
+
total: number;
|
|
4
|
+
invalid: number;
|
|
5
|
+
valid: number;
|
|
6
|
+
fieldsCount: number;
|
|
7
|
+
fields: string[];
|
|
8
|
+
ignoredFields: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface FileImportJobValidationError {
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
rowValue?: Record<string, string>;
|
|
14
|
+
metadata?: {
|
|
15
|
+
row?: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export interface FileImportJob {
|
|
19
|
+
id: string;
|
|
20
|
+
fileName: string;
|
|
21
|
+
importContainerKey: string;
|
|
22
|
+
state: FileImportJobState;
|
|
23
|
+
summary: FileImportJobSummary;
|
|
24
|
+
jobError?: FileImportJobValidationError | null;
|
|
25
|
+
}
|
|
26
|
+
export interface CreateFileImportJobWithStreamPayload {
|
|
27
|
+
fileType: 'csv' | 'json';
|
|
28
|
+
fileName: string;
|
|
29
|
+
file: File;
|
|
30
|
+
}
|
|
31
|
+
export interface CreateFileImportJobWithReferencePayload {
|
|
32
|
+
payloadType: 'fileReference';
|
|
33
|
+
fileName: string;
|
|
34
|
+
fileUrl: string;
|
|
35
|
+
}
|
|
36
|
+
export type CreateFileImportJobPayload = CreateFileImportJobWithStreamPayload | CreateFileImportJobWithReferencePayload;
|
|
37
|
+
export interface CreateFileImportJobParameters {
|
|
38
|
+
projectKey: string;
|
|
39
|
+
resourceType: string;
|
|
40
|
+
importContainerKey: string;
|
|
41
|
+
payload: CreateFileImportJobPayload;
|
|
42
|
+
onProgress?: (progress: number) => void;
|
|
43
|
+
abortSignal?: AbortSignal;
|
|
44
|
+
}
|
|
45
|
+
export interface GetFileImportJobParameters {
|
|
46
|
+
projectKey: string;
|
|
47
|
+
importContainerKey: string;
|
|
48
|
+
jobId: string;
|
|
49
|
+
}
|
|
50
|
+
export interface FileImportJobError {
|
|
51
|
+
code: string;
|
|
52
|
+
message: string;
|
|
53
|
+
field: string;
|
|
54
|
+
}
|
|
55
|
+
export interface FileImportJobErrorRecord {
|
|
56
|
+
index: number;
|
|
57
|
+
errors: FileImportJobError[];
|
|
58
|
+
}
|
|
59
|
+
export interface FileImportJobRecordsResponse {
|
|
60
|
+
results: FileImportJobErrorRecord[];
|
|
61
|
+
total: number;
|
|
62
|
+
limit: number;
|
|
63
|
+
offset: number;
|
|
64
|
+
count: number;
|
|
65
|
+
}
|
|
66
|
+
export interface GetFileImportJobRecordsParameters {
|
|
67
|
+
projectKey: string;
|
|
68
|
+
importContainerKey: string;
|
|
69
|
+
jobId: string;
|
|
70
|
+
limit?: number;
|
|
71
|
+
offset?: number;
|
|
72
|
+
isValid?: boolean;
|
|
73
|
+
}
|
|
74
|
+
export interface ProcessFileImportJobParameters {
|
|
75
|
+
projectKey: string;
|
|
76
|
+
resourceType: string;
|
|
77
|
+
importContainerKey: string;
|
|
78
|
+
jobId: string;
|
|
79
|
+
action?: 'delete';
|
|
80
|
+
}
|
|
81
|
+
export interface ProcessFileImportJobResponse {
|
|
82
|
+
message: string;
|
|
83
|
+
}
|
|
84
|
+
export interface DeleteFileImportJobParameters {
|
|
85
|
+
projectKey: string;
|
|
86
|
+
importContainerKey: string;
|
|
87
|
+
jobId: string;
|
|
88
|
+
}
|
|
89
|
+
export interface ListFileImportJobsParameters {
|
|
90
|
+
projectKey: string;
|
|
91
|
+
importContainerKey: string;
|
|
92
|
+
limit?: number;
|
|
93
|
+
offset?: number;
|
|
94
|
+
}
|
|
95
|
+
export type ListFileImportJobsResponse = FileImportJob[];
|
|
96
|
+
export declare function assertFileImportJob(maybeJob: unknown): asserts maybeJob is FileImportJob;
|
|
97
|
+
export declare function assertFileImportJobRecordsResponse(maybeRecords: unknown): asserts maybeRecords is FileImportJobRecordsResponse;
|
|
98
|
+
export declare function assertProcessFileImportJobResponse(maybeResponse: unknown): asserts maybeResponse is ProcessFileImportJobResponse;
|
|
99
|
+
export declare function assertListFileImportJobsResponse(maybeResponse: unknown): asserts maybeResponse is ListFileImportJobsResponse;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FileImportJob } from "./file-import-job.js";
|
|
2
|
+
import type { RowErrorsResponse } from "./file-upload.js";
|
|
3
|
+
export interface FileUploadResult {
|
|
4
|
+
containerKey: string;
|
|
5
|
+
summary: {
|
|
6
|
+
total: number;
|
|
7
|
+
valid: number;
|
|
8
|
+
invalid: number;
|
|
9
|
+
fieldsCount: number;
|
|
10
|
+
fields: string[];
|
|
11
|
+
ignoredFields: string[];
|
|
12
|
+
/**
|
|
13
|
+
* Validation errors. Format is compatible between old and new flows:
|
|
14
|
+
* - Old flow: { row?: number, index?: number, errors: RowError[] }
|
|
15
|
+
* - New flow: { index: number, errors: FileImportJobError[] }
|
|
16
|
+
*/
|
|
17
|
+
results: Array<RowErrorsResponse>;
|
|
18
|
+
};
|
|
19
|
+
jobId?: string;
|
|
20
|
+
job?: FileImportJob;
|
|
21
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { ResourceTypeId } from '@commercetools/importapi-sdk';
|
|
2
|
+
export type FileUploadError = {
|
|
3
|
+
title: string;
|
|
4
|
+
description: string;
|
|
5
|
+
};
|
|
6
|
+
export type UploadFileErrorRow = {
|
|
7
|
+
id: string;
|
|
8
|
+
row?: number;
|
|
9
|
+
index?: number;
|
|
10
|
+
code: string;
|
|
11
|
+
field: string;
|
|
12
|
+
validationMessage: string;
|
|
13
|
+
};
|
|
14
|
+
export type RowError = {
|
|
15
|
+
code: string;
|
|
16
|
+
message: string;
|
|
17
|
+
field: string;
|
|
18
|
+
};
|
|
19
|
+
export type RowErrorsResponse = {
|
|
20
|
+
row?: number;
|
|
21
|
+
index?: number;
|
|
22
|
+
errors: Array<RowError>;
|
|
23
|
+
};
|
|
24
|
+
export type FileUploadResponse = {
|
|
25
|
+
results: Array<RowErrorsResponse>;
|
|
26
|
+
invalid: number;
|
|
27
|
+
valid: number;
|
|
28
|
+
fileName: string;
|
|
29
|
+
itemsCount: number;
|
|
30
|
+
rowsCount: number;
|
|
31
|
+
columnsCount: number;
|
|
32
|
+
fields: Array<string>;
|
|
33
|
+
ignoredFields: Array<string>;
|
|
34
|
+
};
|
|
35
|
+
export interface FileUploadRequestParameters {
|
|
36
|
+
projectKey: string;
|
|
37
|
+
importContainerKey: string;
|
|
38
|
+
resourceType: ResourceTypeId;
|
|
39
|
+
file: File;
|
|
40
|
+
abortSignal?: AbortSignal;
|
|
41
|
+
onSuccess: (data: FileUploadResponse) => void;
|
|
42
|
+
onProgress: (progress: number) => void;
|
|
43
|
+
onError: (error: Error) => void;
|
|
44
|
+
}
|
|
45
|
+
export interface ProcessUploadedFileRequestParameters {
|
|
46
|
+
projectKey: string;
|
|
47
|
+
importContainerKey: string;
|
|
48
|
+
resourceType: ResourceTypeId;
|
|
49
|
+
action?: 'delete';
|
|
50
|
+
}
|
|
51
|
+
export type ProcessFileResponse = {
|
|
52
|
+
message: string;
|
|
53
|
+
};
|
|
54
|
+
export type MissingCsvFieldIdentifierError = {
|
|
55
|
+
code: string;
|
|
56
|
+
message: string;
|
|
57
|
+
rowValue: Record<string, unknown>;
|
|
58
|
+
metadata: {
|
|
59
|
+
row: number;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
export type DecimalSeparator = '.' | ',';
|
|
63
|
+
export type DropAreaState = 'default' | 'active-drag' | 'ready-for-drop' | 'file-dropped' | 'disabled' | 'invalid' | 'is-parsing';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ImportContainerPagedResponse, ImportContainer, ImportContainerDraft } from '@commercetools/importapi-sdk';
|
|
2
|
+
import { type DecimalSeparator } from "./file-upload.js";
|
|
3
|
+
import { type ExtendedImportSummary, type ImportSummary } from "./import-summary.js";
|
|
4
|
+
import { type ImportStates } from "./import-states.js";
|
|
5
|
+
export declare function assertImportContainerPagedResponse(maybeImportContainerPagedResponse: unknown): asserts maybeImportContainerPagedResponse is ImportContainerPagedResponse;
|
|
6
|
+
export declare function assertImportSummary(maybeImportSummary: unknown): asserts maybeImportSummary is ExtendedImportSummary;
|
|
7
|
+
export declare function assertImportContainer(maybeImportContainerResponse: unknown): asserts maybeImportContainerResponse is ImportContainer;
|
|
8
|
+
export type CancelContainerResponse = {
|
|
9
|
+
message: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function assertCancelContainerResponse(maybeCancelContainerResponse: unknown): asserts maybeCancelContainerResponse is CancelContainerResponse;
|
|
12
|
+
export type ImportContainerQueryParams = {
|
|
13
|
+
limit?: number;
|
|
14
|
+
offset?: number;
|
|
15
|
+
sort?: string;
|
|
16
|
+
tags?: string;
|
|
17
|
+
};
|
|
18
|
+
export interface ExtendedImportContainer extends ImportContainer {
|
|
19
|
+
settings?: {
|
|
20
|
+
resourceType?: string;
|
|
21
|
+
format?: string;
|
|
22
|
+
decimalSeparator?: DecimalSeparator;
|
|
23
|
+
options?: {
|
|
24
|
+
publishAllChanges?: boolean;
|
|
25
|
+
unpublishAllChanges?: boolean;
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
tags?: string[];
|
|
29
|
+
}
|
|
30
|
+
export interface ExtendedImportContainerDraft extends ImportContainerDraft {
|
|
31
|
+
settings?: {
|
|
32
|
+
resourceType?: string;
|
|
33
|
+
format?: string;
|
|
34
|
+
decimalSeparator?: DecimalSeparator;
|
|
35
|
+
options?: {
|
|
36
|
+
publishAllChanges?: boolean;
|
|
37
|
+
unpublishAllChanges?: boolean;
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
tags?: string[];
|
|
41
|
+
}
|
|
42
|
+
export type ImportContainerDetails = {
|
|
43
|
+
importContainer: ExtendedImportContainer;
|
|
44
|
+
importState: ImportStates;
|
|
45
|
+
importSummary: ImportSummary;
|
|
46
|
+
isFileUploadImport: boolean;
|
|
47
|
+
};
|
|
48
|
+
export type ImportSummaries = {
|
|
49
|
+
results: Array<Promise<ImportContainerDetails>>;
|
|
50
|
+
count: number;
|
|
51
|
+
total: number;
|
|
52
|
+
queryParams: ImportContainerQueryParams;
|
|
53
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ImportOperation, ImportOperationPagedResponse } from '@commercetools/importapi-sdk';
|
|
2
|
+
export type ImportOperationQueryParams = {
|
|
3
|
+
limit?: number;
|
|
4
|
+
offset?: number;
|
|
5
|
+
state?: string | string[];
|
|
6
|
+
};
|
|
7
|
+
export interface ExtendedImportOperation extends ImportOperation {
|
|
8
|
+
tags?: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface ExtendedImportOperationPagedResponse extends ImportOperationPagedResponse {
|
|
11
|
+
results: ExtendedImportOperation[];
|
|
12
|
+
}
|
|
13
|
+
export declare function assertImportOperationPagedResponse(maybeImportOperationPagedResponse: unknown): asserts maybeImportOperationPagedResponse is ExtendedImportOperationPagedResponse;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare enum ImportStates {
|
|
2
|
+
Processing = "processing",
|
|
3
|
+
WaitForUnresolvedReferences = "wait-for-unresolved-references",
|
|
4
|
+
PartiallyCompleted = "partially-completed",
|
|
5
|
+
Failed = "failed",
|
|
6
|
+
SuccessfullyCompleted = "successfully-completed",
|
|
7
|
+
NoRunningImports = "no-running-imports",
|
|
8
|
+
Canceled = "canceled"
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { OperationStates, ImportSummary } from '@commercetools/importapi-sdk';
|
|
2
|
+
interface ExtendedOperationStates extends OperationStates {
|
|
3
|
+
/**
|
|
4
|
+
* The number of resources in the `canceled` state.
|
|
5
|
+
*/
|
|
6
|
+
readonly canceled: number;
|
|
7
|
+
/**
|
|
8
|
+
* The number of resources in the `deleted` state.
|
|
9
|
+
*/
|
|
10
|
+
readonly deleted: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ExtendedImportSummary extends ImportSummary {
|
|
13
|
+
readonly states: ExtendedOperationStates;
|
|
14
|
+
}
|
|
15
|
+
export { type ExtendedImportSummary as ImportSummary };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export * from "./api.js";
|
|
2
|
+
export * from "./basic-error-data-type.js";
|
|
3
|
+
export * from "./export-operation.js";
|
|
4
|
+
export * from "./file-upload.js";
|
|
5
|
+
export * from "./file-upload-result.js";
|
|
6
|
+
export * from "./file-import-job.js";
|
|
7
|
+
export * from "./import-container.js";
|
|
8
|
+
export * from "./import-operation.js";
|
|
9
|
+
export * from "./import-states.js";
|
|
10
|
+
export * from "./import-summary.js";
|
|
11
|
+
export * from "./shared.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function hasOwnProperty<X extends {}, Y extends PropertyKey>(obj: X, prop: Y): obj is X & Record<Y, unknown>;
|
|
2
|
+
export declare function hasRequiredFields(maybeValidObject: unknown, requiredFields: Array<string>): boolean;
|
|
3
|
+
export declare function getMissingRequiredFields(maybeValidObject: unknown, requiredFields: Array<string>): string[] | false;
|
|
4
|
+
export declare function isError(maybeError: unknown): maybeError is Error;
|
|
5
|
+
export declare function isAbortError(error: unknown): error is DOMException;
|
|
6
|
+
export declare function isResourceType<T extends string>(maybeResourceType: unknown): maybeResourceType is T;
|
|
7
|
+
export declare function assertResourceType<T extends string>(maybeResourceType: unknown): asserts maybeResourceType is T;
|