How to use @commercetools/custom-objects-importer - 4 common examples

To help you get started, we’ve selected a few @commercetools/custom-objects-importer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github commercetools / nodejs / integration-tests / cli / custom-objects-import.it.js View on Github external
it('should continueOnProblems if `continueOnProblems`', async () => {
      // Set batchSize to 1 so it executes serially
      objectImport = new CustomObjectsImporter(
        {
          apiConfig,
          batchSize: 1,
          continueOnProblems: true,
        },
        logger
      )

      // Make two objects invalid
      customObjects[0].key = ''
      customObjects[1].container = ''

      await objectImport.run(customObjects)
      const summary = objectImport.summaryReport()
      expect(summary).toMatchSnapshot()
      const errors = summary.detailedSummary.errors
github commercetools / nodejs / integration-tests / cli / custom-objects-import.it.js View on Github external
it('should stop import on first errors by default', async () => {
      // Set batchSize to 1 so it executes serially
      objectImport = new CustomObjectsImporter(
        { apiConfig, batchSize: 1 },
        logger
      )

      // Make last two objects invalid
      customObjects[1].key = ''
      customObjects[2].container = ''

      try {
        await objectImport.run(customObjects)
      } catch (e) {
        // should create first object
        expect(e.summary.createdCount).toBe(1)
        // should stop after first error
        expect(e.summary.errors).toHaveLength(1)
        expect(e.summary).toMatchSnapshot()
github commercetools / nodejs / integration-tests / cli / custom-objects-import.it.js View on Github external
beforeEach(() => {
      objectImport = new CustomObjectsImporter({ apiConfig }, logger)
      customObjects = cloneDeep(allCustomObjects)
    })
github sphereio / sphere-node-cli / lib / commands / import.js View on Github external
[allowedTypes.customObject]: (options) => {
    const service = new CustomObjectImporter(Object.assign({}, options.config, {
      apiConfig: {
        host: options.authHost,
        projectKey: options.credentials.project_key,
        credentials: {
          clientId: options.credentials.client_id,
          clientSecret: options.credentials.client_secret,
        },
        apiUrl: options.host,
        protocol: options.protocol,
        oauth_protocol: options.authProtocol,
      },
      accessToken: options.accessToken,
      batchSize: options.batch,
      logger: log,
    }))
    const processFn = service.processStream.bind(service)

@commercetools/custom-objects-importer

Import custom objects to the commercetools platform

MIT
Latest version published 2 years ago

Package Health Score

57 / 100
Full package analysis

Popular @commercetools/custom-objects-importer functions