{"id":19622132,"url":"https://github.com/commercetools/sphere-product-type-import","last_synced_at":"2025-02-26T19:17:17.218Z","repository":{"id":57367408,"uuid":"56495593","full_name":"commercetools/sphere-product-type-import","owner":"commercetools","description":"A library that helps with importing product-types into the Commercetools Platform.","archived":false,"fork":false,"pushed_at":"2023-04-17T04:24:25.000Z","size":1088,"stargazers_count":2,"open_issues_count":6,"forks_count":0,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-02-25T14:56:09.989Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/commercetools.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-04-18T09:40:14.000Z","updated_at":"2024-05-02T20:56:22.000Z","dependencies_parsed_at":"2024-10-11T08:01:38.271Z","dependency_job_id":"aaa46214-3bd7-4bab-9577-d0332007cf0f","html_url":"https://github.com/commercetools/sphere-product-type-import","commit_stats":{"total_commits":32,"total_committers":9,"mean_commits":"3.5555555555555554","dds":0.6875,"last_synced_commit":"dbd3d4b11e213fa67dc565ccc476aa9780fbaf42"},"previous_names":["sphereio/sphere-product-type-import"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercetools%2Fsphere-product-type-import","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercetools%2Fsphere-product-type-import/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercetools%2Fsphere-product-type-import/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/commercetools%2Fsphere-product-type-import/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/commercetools","download_url":"https://codeload.github.com/commercetools/sphere-product-type-import/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240917722,"owners_count":19878308,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T11:26:08.597Z","updated_at":"2025-02-26T19:17:17.197Z","avatar_url":"https://github.com/commercetools.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![commercetools logo](https://cdn.rawgit.com/commercetools/press-kit/master/PNG/72DPI/CT%20logo%20horizontal%20RGB%2072dpi.png)\n\n# sphere-product-type-import\n\n[![Travis][travis-badge]][travis-url]\n[![Codecov][codecov-badge]][codecov-url]\n[![npm][npm-lic-badge]][npm-lic-url]\n[![semantic-release][semantic-release-badge]][semantic-release-url]\n[![Commitizen friendly][commitizen-badge]][commitizen-url]\n[![NPM version][npm-image]][npm-url]\n\nA library that helps with importing [product-types](http://dev.commercetools.com/http-api-projects-productTypes.html) into the [Commercetools Platform](http://www.commercetools.com/).  \nThis library is built to be used in conjunction with [sphere-node-cli](https://github.com/sphereio/sphere-node-cli).\n\nTable of Contents\n=================\n  * [Features](#features)\n  * [Configuration](#configuration)\n  * [Usage](#usage)\n    * [Usage with sphere-node-cli](#usage-with-sphere-node-cli)\n    * [Direct usage](#direct-usage)\n  * [Contributing](#contributing)\n\n## Features\n- Import product types to your CTP project\n- Pre-validate product types using a [JSON schema](https://github.com/sphereio/sphere-product-type-import/blob/master/src/product-type-import.js#L7)\n\n## Configuration\nThe configuration object may contain:\n- `sphereClientConfig`: see the [sphere-node-sdk docs](http://sphereio.github.io/sphere-node-sdk/) for more information on this\n\n## Usage\n\n### Usage with `sphere-node-cli`\n\nYou can use the product type import from the command line using the [`sphere-node-cli`](https://github.com/sphereio/sphere-node-cli).\nIn order for the cli to import product types, the file to import from must be JSON and follow the this structure:\n```\n{\n  \"productTypes\": [\n    \u003cproduct-type\u003e,\n    \u003cproduct-type\u003e,\n    ...\n  ]\n}\n```\nThen you can import this file using the cli:\n```\nsphere-node-cli -t productType -p my-project-key -f /sample_dir/productTypes.json\n```\nYou can pass a custom configuration as described above via the `-c` operator followed by a JSON String that represents your configuration\n\n### Direct usage\n\nIf you want more control, you can also use this library directly in JavaScript. To do this you first need to install it:\n```\nnpm install sphere-product-type-import --save-dev\n```\nThen you can use it to import product types like so:\n```\nimport ProductTypeImport from 'sphere-product-type-import'\n\nconst productType = {\n  name: '\u003csome-name\u003e',\n  description: '\u003csome-description\u003e'\n}\nconst config = {\n  importerConfig: {\n    continueOnProblems: false\n  },\n  sphereClientConfig: {\n    config: {\n      project_key: \u003cPROJECT_KEY\u003e,\n      client_id: '*********',\n      client_secret: '*********'\n    }\n  }\n}\nconst productTypeImport = ProductTypeImport(config)\n\nproductTypeImport.importProductType(productType)\n.then(() =\u003e {\n  // done importing the productType\n  // look at the summary to see errors\n  productTypeImport.summary\n  // the summary hast the following structure\n  // {\n  //   errors: [],\n  //   inserted: [\u003csome-name\u003e],\n  //   successfulImports: 1\n  // }\n})\n```\n\nWhen there is an error during processing productTypes, process will by default save this error to `summary.errors` array and reject. If the configuration flag `importerConfig.continueOnProblems` is set to `true` the importer will only push error to summary and then continue with next productType.\n \n## Contributing\n  See [CONTRIBUTING.md](CONTRIBUTING.md) file for info on how to contribute to this library\n\n[travis-badge]: https://img.shields.io/travis/sphereio/sphere-product-type-import.svg?style=flat-square\n[travis-url]: https://travis-ci.org/sphereio/sphere-product-type-import\n\n[codecov-badge]: https://img.shields.io/codecov/c/github/sphereio/sphere-product-type-import.svg?style=flat-square\n[codecov-url]: https://codecov.io/github/sphereio/sphere-product-type-import\n\n[npm-lic-badge]: https://img.shields.io/npm/l/sphere-product-type-import.svg?style=flat-square\n[npm-lic-url]: http://spdx.org/licenses/MIT\n\n[semantic-release-badge]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square\n[semantic-release-url]: https://github.com/semantic-release/semantic-release\n\n[commitizen-badge]: https://img.shields.io/badge/commitizen-friendly-brightgreen.svg?style=flat-square\n[commitizen-url]: http://commitizen.github.io/cz-cli/\n\n[npm-url]: https://npmjs.org/package/sphere-product-type-import\n[npm-image]: http://img.shields.io/npm/v/sphere-product-type-import.svg?style=flat-square\n[npm-downloads-image]: https://img.shields.io/npm/dt/sphere-product-type-import.svg?style=flat-square\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommercetools%2Fsphere-product-type-import","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcommercetools%2Fsphere-product-type-import","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcommercetools%2Fsphere-product-type-import/lists"}