@commercetools-frontend-extensions/export-resources-modal 0.0.0-bw-test-preview-deploy-20250115163227

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.
Files changed (50) hide show
  1. package/LICENSE +29 -0
  2. package/README.md +386 -0
  3. package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.d.ts +3 -0
  4. package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.dev.js +2080 -0
  5. package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.js +7 -0
  6. package/dist/commercetools-frontend-extensions-export-resources-modal.cjs.prod.js +2050 -0
  7. package/dist/commercetools-frontend-extensions-export-resources-modal.esm.js +2037 -0
  8. package/dist/de-3d4cf3d0.cjs.prod.js +237 -0
  9. package/dist/de-abc94d19.esm.js +235 -0
  10. package/dist/de-d6a38e9e.cjs.dev.js +237 -0
  11. package/dist/declarations/src/@constants/delimiters.d.ts +4 -0
  12. package/dist/declarations/src/@constants/export-operation-states.d.ts +6 -0
  13. package/dist/declarations/src/@constants/export-types.d.ts +5 -0
  14. package/dist/declarations/src/@constants/exportable-resources.d.ts +9 -0
  15. package/dist/declarations/src/@constants/index.d.ts +8 -0
  16. package/dist/declarations/src/@constants/misc.d.ts +3 -0
  17. package/dist/declarations/src/@constants/output-formats.d.ts +8 -0
  18. package/dist/declarations/src/@constants/resource-type-messages.d.ts +10 -0
  19. package/dist/declarations/src/@constants/urls.d.ts +2 -0
  20. package/dist/declarations/src/@hooks/index.d.ts +4 -0
  21. package/dist/declarations/src/@hooks/use-convert-field-definitions-for-export.d.ts +9 -0
  22. package/dist/declarations/src/@hooks/use-export-resources-modal-context.d.ts +2 -0
  23. package/dist/declarations/src/@hooks/use-initial-values.d.ts +2 -0
  24. package/dist/declarations/src/@hooks/use-start-export-operation.d.ts +4 -0
  25. package/dist/declarations/src/@types/export-api.d.ts +30 -0
  26. package/dist/declarations/src/@types/export-resources-modal-context.d.ts +22 -0
  27. package/dist/declarations/src/@types/export-resources-modal-types.d.ts +49 -0
  28. package/dist/declarations/src/@types/field-definition.d.ts +7 -0
  29. package/dist/declarations/src/@types/form.d.ts +37 -0
  30. package/dist/declarations/src/@types/index.d.ts +7 -0
  31. package/dist/declarations/src/@types/output-format.d.ts +1 -0
  32. package/dist/declarations/src/@types/resource-type.d.ts +5 -0
  33. package/dist/declarations/src/export-resources-modal.d.ts +6 -0
  34. package/dist/declarations/src/index.d.ts +5 -0
  35. package/dist/en-0ea9f92c.cjs.dev.js +237 -0
  36. package/dist/en-38313842.esm.js +235 -0
  37. package/dist/en-fc0085cc.cjs.prod.js +237 -0
  38. package/dist/es-6360d546.cjs.prod.js +237 -0
  39. package/dist/es-85c5a396.esm.js +235 -0
  40. package/dist/es-a4227b21.cjs.dev.js +237 -0
  41. package/dist/fr-FR-1602d5ff.cjs.dev.js +237 -0
  42. package/dist/fr-FR-e610590b.esm.js +235 -0
  43. package/dist/fr-FR-ff7ec057.cjs.prod.js +237 -0
  44. package/dist/ja-37632763.cjs.prod.js +6 -0
  45. package/dist/ja-73c088a7.esm.js +4 -0
  46. package/dist/ja-9bd5f452.cjs.dev.js +6 -0
  47. package/dist/pt-BR-7b17be9e.cjs.dev.js +237 -0
  48. package/dist/pt-BR-ccc18639.esm.js +235 -0
  49. package/dist/pt-BR-d9b0a36d.cjs.prod.js +237 -0
  50. package/package.json +81 -0
package/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) commercetools GmbH
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ 1. Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ 2. Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ 3. Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/README.md ADDED
@@ -0,0 +1,386 @@
1
+ # @commercetools-frontend-extensions/export-resources-modal
2
+
3
+ Package for exporting resources from Merchant Center Applications.
4
+
5
+ > This library takes into account that you are building a Merchant Center Applications which documentation you can find [here](https://docs.commercetools.com/custom-applications/).
6
+ > The components follow the same principles of the [UIKit](https://github.com/commercetools/ui-kit) components.
7
+
8
+ ## Getting started
9
+
10
+ ```bash
11
+ $ npm install --save @commercetools-frontend-extensions/export-resources-modal
12
+
13
+ // or
14
+
15
+ $ yarn add @commercetools-frontend-extensions/export-resources-modal
16
+ ```
17
+
18
+ ## Description
19
+
20
+ Export Resources Modal is an internal component used to export resources into csv or json files, it's using [Exporter Services](https://github.com/commercetools/commercetools-exporter) to create async export Job.
21
+
22
+ ## Usage
23
+
24
+ ```js
25
+ import ExportResourcesModal from '@commercetools-frontend-extensions/export-resources-modal';
26
+
27
+ // Use case: Exporting all resources
28
+ <ExportResourcesModal
29
+ isOpen={true}
30
+ outputFormat="csv"
31
+ resourceType="category"
32
+ totalResourcesCount={143}
33
+ fieldGroups={[
34
+ {
35
+ groupLabel: 'All general fields',
36
+ groupName: 'general-fields',
37
+ fields: [
38
+ {
39
+ name: 'key',
40
+ label: 'Category key',
41
+ isRequired: true,
42
+ },
43
+ {
44
+ name: 'externalId',
45
+ label: 'External id',
46
+ },
47
+ {
48
+ name: 'createdAt',
49
+ label: 'Created at',
50
+ isSelectedByDefault: true,
51
+ },
52
+ {
53
+ name: 'lastModifiedAt',
54
+ label: 'Last modified at',
55
+ isSelectedByDefault: true,
56
+ },
57
+ { name: 'name', label: 'Name', isSelectedByDefault: true },
58
+ {
59
+ name: 'parent',
60
+ label: 'parent',
61
+ isSelectedByDefault: true,
62
+ fields: [
63
+ {
64
+ name: 'parent.name',
65
+ label: 'Parent name',
66
+ },
67
+ {
68
+ name: 'parent.key',
69
+ label: 'Parent key',
70
+ },
71
+ ],
72
+ },
73
+ {
74
+ name: 'id',
75
+ label: 'Id',
76
+ isSelectedByDefault: true,
77
+ },
78
+ ],
79
+ },
80
+ {
81
+ groupLabel: 'All custom fields',
82
+ groupName: 'custom-fields',
83
+ fields: [
84
+ {
85
+ name: 'custom-type-key-and-type-id',
86
+ label: 'Custom type key and type id',
87
+ },
88
+ {
89
+ name: 'general-category-attributes',
90
+ label: 'General category attributes',
91
+ fields: [
92
+ {
93
+ name: 'custom.fields.season',
94
+ label: 'Season',
95
+ },
96
+ {
97
+ name: 'custom.fields.target-audience',
98
+ label: 'Target audience',
99
+ },
100
+ ],
101
+ },
102
+ {
103
+ name: 'book-category-attributes',
104
+ label: 'Book category attributes',
105
+ fields: [
106
+ {
107
+ name: 'custom.fields.genre',
108
+ label: 'Genre',
109
+ },
110
+ {
111
+ name: 'custom.fields.age-group',
112
+ label: 'Age group',
113
+ },
114
+ ],
115
+ },
116
+ ],
117
+ },
118
+ ]}
119
+ fieldOrder={['*', 'custom']}
120
+ onClose={() => {
121
+ ...
122
+ }}
123
+ />
124
+
125
+
126
+ // Use case: Exporting filtered resources
127
+ <ExportResourcesModal
128
+ isOpen={true}
129
+ outputFormat="csv"
130
+ resourceType="category"
131
+ filters={{
132
+ {
133
+ filters: [ 'key = "category-key"'],
134
+ fullText: {
135
+ text: 'category-text',
136
+ locale: 'en'
137
+ }
138
+ },
139
+ total: 20
140
+ }}
141
+ totalResourcesCount={143}
142
+ fieldGroups={[
143
+ {
144
+ groupLabel: 'All general fields',
145
+ groupName: 'general-fields',
146
+ fields: [
147
+ {
148
+ name: 'key',
149
+ label: 'Category key',
150
+ isRequired: true,
151
+ },
152
+ {
153
+ name: 'externalId',
154
+ label: 'External id',
155
+ },
156
+ {
157
+ name: 'createdAt',
158
+ label: 'Created at',
159
+ isSelectedByDefault: true,
160
+ },
161
+ {
162
+ name: 'lastModifiedAt',
163
+ label: 'Last modified at',
164
+ isSelectedByDefault: true,
165
+ },
166
+ { name: 'name', label: 'Name', isSelectedByDefault: true },
167
+ {
168
+ name: 'parent',
169
+ label: 'parent',
170
+ isSelectedByDefault: true,
171
+ fields: [
172
+ {
173
+ name: 'parent.name',
174
+ label: 'Parent name',
175
+ },
176
+ {
177
+ name: 'parent.key',
178
+ label: 'Parent key',
179
+ },
180
+ ],
181
+ },
182
+ {
183
+ name: 'id',
184
+ label: 'Id',
185
+ isSelectedByDefault: true,
186
+ },
187
+ ],
188
+ },
189
+ {
190
+ groupLabel: 'All custom fields',
191
+ groupName: 'custom-fields',
192
+ fields: [
193
+ {
194
+ name: 'custom-type-key-and-type-id',
195
+ label: 'Custom type key and type id',
196
+ },
197
+ {
198
+ name: 'general-category-attributes',
199
+ label: 'General category attributes',
200
+ fields: [
201
+ {
202
+ name: 'custom.fields.season',
203
+ label: 'Season',
204
+ },
205
+ {
206
+ name: 'custom.fields.target-audience',
207
+ label: 'Target audience',
208
+ },
209
+ ],
210
+ },
211
+ {
212
+ name: 'book-category-attributes',
213
+ label: 'Book category attributes',
214
+ fields: [
215
+ {
216
+ name: 'custom.fields.genre',
217
+ label: 'Genre',
218
+ },
219
+ {
220
+ name: 'custom.fields.age-group',
221
+ label: 'Age group',
222
+ },
223
+ ],
224
+ },
225
+ ],
226
+ },
227
+ ]}
228
+ fieldOrder={['*', 'custom']}
229
+ onClose={() => {
230
+ ...
231
+ }}
232
+ />
233
+
234
+ // Use case: Exporting only selected resources by their IDs
235
+ <ExportResourcesModal
236
+ isOpen={true}
237
+ outputFormat="csv"
238
+ resourceType="category"
239
+ selectedResourceIds={['02ed9a7d-7c1f-40da-b2b7-4cca6752bf29', '04051276-1641-4e01-a03e-d4de16b7e4eb', 'ac7d9f7b-5c7d-4dd3-b82b-8555ab4a2a6e']}
240
+ fields={[
241
+ {
242
+ groupLabel: 'All General fields',
243
+ groupName: 'general-fields',
244
+ fields:[
245
+ {
246
+ name: 'key',
247
+ label: 'Category key',
248
+ isRequired: true,
249
+ isSelectedByDefault: true,
250
+ },
251
+ {
252
+ name: 'externalId',
253
+ label: 'External id',
254
+ },
255
+ { name: 'createdAt', label: 'Created at', isSelectedByDefault: true, },
256
+ { name: 'lastModifiedAt', label: 'Last modified at', isSelectedByDefault: true, },
257
+ { name: 'name', label: 'Name', isSelectedByDefault: true, },
258
+ {
259
+ name: 'parent',
260
+ isSelectedByDefault: true,
261
+ fields: [
262
+ {
263
+ name: 'parent.name',
264
+ label: 'Parent name',
265
+ },
266
+ {
267
+ name: 'parent.key',
268
+ label: 'Parent key',
269
+ },
270
+ ],
271
+ },
272
+ {
273
+ name: 'id',
274
+ label: 'Id',
275
+ },
276
+ ]
277
+ },
278
+ {
279
+ groupLabel: 'All custom fields',
280
+ groupName: 'custom-fields',
281
+ fields: [
282
+ {
283
+ name: 'custom-type-key-and-typeid',
284
+ label: 'Custom type key and type id',
285
+ isSelectedByDefault: false,
286
+ },
287
+ {
288
+ name: 'general-category-attributes',
289
+ label: 'General category attributes',
290
+ isSelectedByDefault: false,
291
+ fields: [
292
+ {
293
+ name: 'season',
294
+ label: 'Season',
295
+ },
296
+ {
297
+ name: 'target-audience',
298
+ label: 'Target audience',
299
+ },
300
+ ],
301
+ },
302
+ {
303
+ name: 'book-category-attributes',
304
+ label: 'Book category attributes',
305
+ isSelectedByDefault: false,
306
+ fields: [
307
+ {
308
+ name: 'genre',
309
+ label: 'Genre',
310
+ },
311
+ {
312
+ name: 'age-group',
313
+ label: 'Age group',
314
+ },
315
+ ],
316
+ },
317
+ ]
318
+ }
319
+ ]}
320
+ onClose={() => {
321
+ ...
322
+ }}
323
+ />
324
+ ```
325
+
326
+ ## Properties
327
+
328
+ | Props | Type | Required | Default | Description |
329
+ | -------------------------------------------- | ------------------------------------------------------- | :--------------------------------------------------: | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
330
+ | `isOpen` | `boolean` | | `false` | Controls whether the export modal is open or closed |
331
+ | `outputFormat` | `string`<br/>Possible values: `csv`, `json` | | `csv` | The file format to export |
332
+ | `onExportSuccess` | `function` | | | Callback function that is called when the export operation is successful |
333
+ | `onClose` | `function` | | | Callback function invoked when the modal is requested to close (on overlay click, close button click or `ESC` press). This function is also called after an export operation regardless of its success or failure |
334
+ | `resourceType` | `string` | ✅ | | The type of the resource, example: `category`, `product`...
335
+ | `filters` | `Filters` | | | Filters can be set as filters object with a `query` property or array of strings. It can also be set as a simple string for the `where` property. Lastly, another option is to set Filters as `fulltext` object with `text` and locale` string properties.
336
+ | `totalResourcesCount` | `number` | ✅ | | The count of all resources of identified `resourceType` |
337
+ | `selectedResourceIds` | `array` | | | Array of Ids of the selected resources |
338
+ | `fieldGroups` | `array` | ✅ | | Array of the grouped `fields` to export. |
339
+ | `fieldGroups[].groupLabel` | `string` | ✅ | | The label of the field group to be shown in the export modal |
340
+ | `fieldGroups[].groupName` | `string` | ✅ | | The name of the field group used to determine the state of expanded groups |
341
+ | `fieldGroups[].isExpanded` | `string` | | `false` | This property used to control the default state of each expandable group section in the UI. If `isExpanded` is set to `true`, then the corresponding group will be expanded when the component loads. The default value is `false` which means unless explicitly set to `true`, the group will be collapsed on initial load |
342
+ | `fieldGroups[].fields` | `array` | ✅ | | Array of the fields to export. The fields must align with the [commercetools API schema](https://docs.commercetools.com/api/). Field can have nested `fields` array. |
343
+ | `fieldGroups[].fields[].name` | `string` | ✅ | | A string that represents the unique identifier for each field. The leaf fields must align with the commercetools HTTP API fields, while parent fields can be developer-specific and created for grouping purposes. |
344
+ | `fieldGroups[].fields[].label` | `string` | ✅ | | The label of the field to be shown in the export modal |
345
+ | `fieldGroups[].fields[].isRequired` | `boolean` | | `false` | `isRequired` field indicates whether a field is required for the export process. If `true` the field will be selected by default and cannot be deselected by the user. This is useful for fields that are essential for the export process. Fields marked as required will have a `*` appended to their label in the UI |
346
+ | `fieldGroups[].fields[].extendedFieldNames` | `array` | | | An array of additional field names that should be included along with the main field name when exporting data. |
347
+ | `fieldGroups[].fields[].dependentGroupNames` | `array` | | | The array of group names provided determines the state of the checkbox. If any of the groups mentioned in the `dependentGroupNames` has at least one checkbox selected, then the field is automatically selected. Optionally, `dependentFieldNames` can be used to specify particular fields within the group. <br>**Note:** The field will be readonly if it has dependencies. |
348
+ | `fieldGroups[].fields[].dependentFieldNames` | `array` | | | The array of field names of specific fields within the group to determine the state of the checkbox. If any of the specified fields in the `dependentFieldNames` are checked, the field is automatically selected. |
349
+ | `fieldGroups[].fields[].isSelectedByDefault` | `boolean` | | `false` | This field is a part of the `fields` array is used to control the default state of the corresponding checkbox in the UI. If `isSelectedByDefault` is set to true, the checkbox for that particular field will be checked by default when the component loads. |
350
+ | `fieldGroups[].fields[].isExpandable` | `boolean` | | `false`| `isExpandable` property indicates if the field can be expanded/collapsed on the UI. If the `isExpandable` is passed as true, then a expand/collapse button is displayed on the UI to control |
351
+ | `fieldGroups[].fields[].isExpanded` | `boolean` | | `false` | This property is used along with `fieldGroups[].fields[].isExpandable` to control the default state of each expandable fields in the UI. If `fieldGroups[].fields[].isExpanded` is set to `true`, then the corresponding field will be expanded when the component loads. The default value is `false` which means unless explicitly set to `true`, the field will be collapsed on initial load |
352
+ | `fieldOrder` | `string[]` | | | The field names are sorted based on the order passed. The value `*` can be passed to denote any fields and for example fieldOrder=['*', 'custom'] will push all the fields that starts with custom to the last in the list and any other fields will be at the beginning of the list |
353
+
354
+ ## Releasing
355
+
356
+ This package uses [`changesets`](https://github.com/atlassian/changesets) in order to do releases to NPM.
357
+
358
+ In case you want to publish a new version with the latest changes you need to:
359
+
360
+ 1. Add a changeset with `pnpm changeset` and select `@commercetools-frontend-extensions/export-resources-modal` as the modified package.
361
+ 2. Some options would be appear in order to do the release:
362
+ - `patch`: use this release for fixes or small changes
363
+ - `minor`: use this release for depenency upgrades or medium changes
364
+ - `major`: use this release for breaking changes
365
+ 3. After selecting the option you will need to add a comment for the release notes. We recommend to use the same format as for the commits.
366
+ - e.g: `feat(utils): add utils for dates`
367
+ 4. Push the `changeset` to your branch and GitHub actions will detect that the PR contains changes that affect the published library.
368
+ 5. After the PR gets merged, another PR will be created called `Version Packages` which is the one that will be detected, again by GitHub Actions, to do a release to NPM.
369
+ 6. Make sure that everything is correct and then merge `Version Packages` PR.
370
+ 7. Wait until the new version is available in NPM and then deploy the custom in CircleCI.
371
+
372
+ ### Canary releases
373
+
374
+ Canary releases are automatically published to the distribution channel via CI following a successful build and merge to the **main** branch.
375
+
376
+ ## i18n
377
+
378
+ The repo is configured with an integration with Transifex. The process for i18n is the same as the Merchant Center uses.
379
+
380
+ `pnpm i18n:build` for adding the new keys to transifex.
381
+
382
+ Once the PR gets merged to `main` transifex will receive a notification with new keys that need to be translated (that's why is important that `description` and `defaultMessage` are descriptive enough).
383
+
384
+ Whenever the translators finish translations and mark them as done, the repo will receive a PR (per language) for adding translated messages.
385
+
386
+ Once we review that translated keys are correct and add a `changeset` we can merge the PR. (Don't forget to deploy the custom app)
@@ -0,0 +1,3 @@
1
+ export * from "./declarations/src/index.js";
2
+ export { default } from "./declarations/src/index.js";
3
+ //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVyY2V0b29scy1mcm9udGVuZC1leHRlbnNpb25zLWV4cG9ydC1yZXNvdXJjZXMtbW9kYWwuY2pzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuL2RlY2xhcmF0aW9ucy9zcmMvaW5kZXguZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9