xladmin-import-export 0.1.0 → 0.1.2

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/README.md CHANGED
@@ -30,10 +30,10 @@ npm i xladmin xladmin-import-export
30
30
  import {ModelPage} from 'xladmin';
31
31
  import {
32
32
  ModelImportExportActions,
33
- createAxiosXLAdminImportExportClient,
33
+ createAxiosAdminImportExportClient,
34
34
  } from 'xladmin-import-export';
35
35
 
36
- const importExportClient = createAxiosXLAdminImportExportClient(api);
36
+ const importExportClient = createAxiosAdminImportExportClient(api);
37
37
 
38
38
  <ModelPage
39
39
  client={client}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { XLAdminRequestOptions, ModelPageToolbarContext } from 'xladmin';
1
+ import { AdminRequestOptions, ModelPageToolbarContext } from 'xladmin';
2
2
  import * as react_jsx_runtime from 'react/jsx-runtime';
3
3
 
4
4
  type ImportExportFieldMeta = {
@@ -71,7 +71,7 @@ type DownloadExportResponse = {
71
71
  blob: Blob;
72
72
  filename: string;
73
73
  };
74
- type XLAdminImportExportAxiosLike = {
74
+ type AdminImportExportAxiosLike = {
75
75
  get: <T>(url: string, config?: {
76
76
  signal?: AbortSignal;
77
77
  }) => Promise<{
@@ -86,25 +86,25 @@ type XLAdminImportExportAxiosLike = {
86
86
  headers?: Record<string, string>;
87
87
  } | T>;
88
88
  };
89
- type XLAdminImportExportClient = {
90
- getMeta: (slug: string, options?: XLAdminRequestOptions) => Promise<ImportExportMetaResponse>;
91
- downloadExport: (slug: string, payload: ExportRequestPayload, options?: XLAdminRequestOptions) => Promise<DownloadExportResponse>;
92
- validateImport: (slug: string, payload: ImportRequestPayload, options?: XLAdminRequestOptions) => Promise<ImportValidationResponse>;
93
- commitImport: (slug: string, payload: ImportRequestPayload, options?: XLAdminRequestOptions) => Promise<ImportCommitResponse>;
89
+ type AdminImportExportClient = {
90
+ getMeta: (slug: string, options?: AdminRequestOptions) => Promise<ImportExportMetaResponse>;
91
+ downloadExport: (slug: string, payload: ExportRequestPayload, options?: AdminRequestOptions) => Promise<DownloadExportResponse>;
92
+ validateImport: (slug: string, payload: ImportRequestPayload, options?: AdminRequestOptions) => Promise<ImportValidationResponse>;
93
+ commitImport: (slug: string, payload: ImportRequestPayload, options?: AdminRequestOptions) => Promise<ImportCommitResponse>;
94
94
  };
95
- type XLAdminImportExportFetchClientConfig = {
95
+ type AdminImportExportFetchClientConfig = {
96
96
  baseUrl: string;
97
97
  fetch?: typeof globalThis.fetch;
98
98
  headers?: HeadersInit | (() => HeadersInit | Promise<HeadersInit>);
99
99
  credentials?: RequestCredentials;
100
100
  };
101
- declare function createAxiosXLAdminImportExportClient(api: XLAdminImportExportAxiosLike): XLAdminImportExportClient;
102
- declare function createFetchXLAdminImportExportClient(config: XLAdminImportExportFetchClientConfig): XLAdminImportExportClient;
101
+ declare function createAxiosAdminImportExportClient(api: AdminImportExportAxiosLike): AdminImportExportClient;
102
+ declare function createFetchAdminImportExportClient(config: AdminImportExportFetchClientConfig): AdminImportExportClient;
103
103
 
104
104
  type ModelImportExportActionsProps = {
105
- client: XLAdminImportExportClient;
105
+ client: AdminImportExportClient;
106
106
  context: ModelPageToolbarContext;
107
107
  };
108
108
  declare function ModelImportExportActions({ client, context }: ModelImportExportActionsProps): react_jsx_runtime.JSX.Element | null;
109
109
 
110
- export { type DownloadExportResponse, type ExportRequestPayload, type ImportCommitResponse, type ImportConflictMode, type ImportExportFieldMeta, type ImportExportFormat, type ImportExportMetaResponse, type ImportExportSelectionScope, type ImportRequestPayload, type ImportValidationResponse, ModelImportExportActions, type XLAdminImportExportAxiosLike, type XLAdminImportExportClient, type XLAdminImportExportFetchClientConfig, createAxiosXLAdminImportExportClient, createFetchXLAdminImportExportClient };
110
+ export { type AdminImportExportAxiosLike, type AdminImportExportClient, type AdminImportExportFetchClientConfig, type DownloadExportResponse, type ExportRequestPayload, type ImportCommitResponse, type ImportConflictMode, type ImportExportFieldMeta, type ImportExportFormat, type ImportExportMetaResponse, type ImportExportSelectionScope, type ImportRequestPayload, type ImportValidationResponse, ModelImportExportActions, createAxiosAdminImportExportClient, createFetchAdminImportExportClient };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/client.ts
2
- function createAxiosXLAdminImportExportClient(api) {
2
+ function createAxiosAdminImportExportClient(api) {
3
3
  return {
4
4
  async getMeta(slug, options) {
5
5
  return unwrap(await api.get(`/xladmin/models/${slug}/import-export/meta/`, {
@@ -45,7 +45,7 @@ function createAxiosXLAdminImportExportClient(api) {
45
45
  }
46
46
  };
47
47
  }
48
- function createFetchXLAdminImportExportClient(config) {
48
+ function createFetchAdminImportExportClient(config) {
49
49
  var _a;
50
50
  const fetchImpl = (_a = config.fetch) != null ? _a : globalThis.fetch;
51
51
  if (!fetchImpl) {
@@ -94,6 +94,9 @@ async function buildImportFormData(payload) {
94
94
  return formData;
95
95
  }
96
96
  async function createStableUploadFile(file) {
97
+ if (typeof file.arrayBuffer !== "function") {
98
+ return file;
99
+ }
97
100
  const buffer = await file.arrayBuffer();
98
101
  return new File([buffer], file.name, {
99
102
  type: file.type,
@@ -724,6 +727,6 @@ function getMessages(locale) {
724
727
  }
725
728
  export {
726
729
  ModelImportExportActions,
727
- createAxiosXLAdminImportExportClient,
728
- createFetchXLAdminImportExportClient
730
+ createAxiosAdminImportExportClient,
731
+ createFetchAdminImportExportClient
729
732
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xladmin-import-export",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Optional import/export extension for xladmin.",
5
5
  "license": "MIT",
6
6
  "type": "module",