@deliverart/sdk-js-customer

中文文档
3.0.1发布于 2026/11/11TypeScriptESM + CJS近 30 天下载 3725

Deliverart JavaScript SDK for Customer and CustomerAddress Management

原始使用文档
文档目录10 节
  1. Installation
  2. Exported Types
  3. Core Types
  4. IRI Types
  5. Available Requests
  6. Customer Management
  7. Customer Addresses
  8. Business Profiles (B2B)
  9. Complete Usage Example
  10. License

@deliverart/sdk-js-customer

Customer and business profile management package for the DeliverArt JavaScript SDK.

Installation

npm install @deliverart/sdk-js-customer @deliverart/sdk-js-core

Exported Types

Core Types

  • Customer - Customer basic information
  • CustomerDetails - Extended customer with relations
  • CustomerAddress - Customer delivery address
  • CustomerBusinessProfile - Business profile for B2B customers

IRI Types

  • CustomerIri - Customer IRI (/customers/:id)
  • CustomerAddressIri - Customer address IRI (/customer_addresses/:id)
  • CustomerBusinessProfileIri - Business profile IRI (/customer_business_profiles/:id)

Available Requests

Customer Management

CreateCustomer

import { CreateCustomer } from '@deliverart/sdk-js-customer';

const customer = await sdk.call(new CreateCustomer({
  firstName: 'John',
  lastName: 'Doe',
  email: '[email protected]',
  phoneNumber: '+39123456789',
  company: '/companies/123' // Optional
}));

Input Parameters:

  • firstName: string (required) - First name
  • lastName: string (required) - Last name
  • email: string (required) - Email address
  • phoneNumber: string (required) - Phone number
  • company?: string (optional) - Company IRI

CreateCustomerFromCurrentUser

import { CreateCustomerFromCurrentUser } from '@deliverart/sdk-js-customer';

const customer = await sdk.call(new CreateCustomerFromCurrentUser({
  pointOfSale: '/point_of_sales/123',
  firstName: 'John',
  lastName: 'Doe',
  email: '[email protected]',
  phoneNumber: null
}));

Creates or returns the POS-scoped customer relationship for the authenticated consumer user. This is the ecommerce account flow: the Deliverart user remains global, while each seller still gets a reliable local Customer profile for CRM, addresses, stats, and order history.

Input Parameters:

  • pointOfSale: string (required) - Point of sale IRI
  • firstName: string | null (required) - First name fallback for the customer profile
  • lastName: string | null (required) - Last name fallback for the customer profile
  • email: string | null (required) - Email fallback for the customer profile
  • phoneNumber: string | null (required) - Phone fallback for the customer profile

GetCustomers

import { GetCustomers } from '@deliverart/sdk-js-customer';

const customers = await sdk.call(new GetCustomers({
  query: {
    email: '[email protected]',
    phoneNumber: '+39123456789',
    page: 1
  }
}));

Query Parameters:

  • firstName?: string - Filter by first name
  • lastName?: string - Filter by last name
  • email?: string - Filter by email
  • phoneNumber?: string - Filter by phone number
  • company?: string - Filter by company IRI
  • page?: number - Page number

GetCustomerDetails

import { GetCustomerDetails } from '@deliverart/sdk-js-customer';

const customer = await sdk.call(new GetCustomerDetails('customer-123'));

UpdateCustomer

import { UpdateCustomer } from '@deliverart/sdk-js-customer';

const updated = await sdk.call(new UpdateCustomer('customer-123', {
  firstName: 'Jane'
}));

DeleteCustomer

import { DeleteCustomer } from '@deliverart/sdk-js-customer';

await sdk.call(new DeleteCustomer('customer-123'));

Customer Addresses

CreateCustomerAddress

import { CreateCustomerAddress } from '@deliverart/sdk-js-customer';

const address = await sdk.call(new CreateCustomerAddress({
  customer: '/customers/123',
  street: 'Via Roma 1',
  city: 'Milano',
  postalCode: '20100',
  country: 'IT',
  location: {
    latitude: 45.464664,
    longitude: 9.188540
  }
}));

Input Parameters:

  • customer: string (required) - Customer IRI
  • street: string (required) - Street address
  • city: string (required) - City
  • postalCode: string (required) - Postal code
  • country: string (required) - Country code (ISO 3166-1 alpha-2)
  • state?: string (optional) - State/region
  • province?: string (optional) - Province
  • location?: { latitude: number, longitude: number } (optional) - GPS coordinates

GetCustomerAddresses

import { GetCustomerAddresses } from '@deliverart/sdk-js-customer';

const addresses = await sdk.call(new GetCustomerAddresses({
  query: {
    customer: '/customers/123'
  }
}));

UpdateCustomerAddress

import { UpdateCustomerAddress } from '@deliverart/sdk-js-customer';

const updated = await sdk.call(new UpdateCustomerAddress('address-123', {
  street: 'Via Nuova 10'
}));

DeleteCustomerAddress

import { DeleteCustomerAddress } from '@deliverart/sdk-js-customer';

await sdk.call(new DeleteCustomerAddress('address-123'));

Business Profiles (B2B)

CreateCustomerBusinessProfile

import { CreateCustomerBusinessProfile } from '@deliverart/sdk-js-customer';

const profile = await sdk.call(new CreateCustomerBusinessProfile({
  customer: '/customers/123',
  businessName: 'Acme Inc',
  vat: 'IT12345678901',
  taxCode: 'ACME123',
  billingAddress: {
    street: 'Via Business 1',
    city: 'Milano',
    postalCode: '20100',
    country: 'IT'
  },
  billingData: {
    email: '[email protected]',
    pec: '[email protected]'
  }
}));

Input Parameters:

  • customer: string (required) - Customer IRI
  • businessName: string (required) - Business name
  • vat: string (required) - VAT number
  • taxCode?: string (optional) - Tax code
  • billingAddress: Address (required) - Billing address
  • billingData: BillingData (required) - Billing contact information

GetCustomerBusinessProfiles

import { GetCustomerBusinessProfiles } from '@deliverart/sdk-js-customer';

const profiles = await sdk.call(new GetCustomerBusinessProfiles({
  query: {
    customer: '/customers/123'
  }
}));

UpdateCustomerBusinessProfile

import { UpdateCustomerBusinessProfile } from '@deliverart/sdk-js-customer';

const updated = await sdk.call(new UpdateCustomerBusinessProfile('profile-123', {
  businessName: 'Acme Corporation'
}));

DeleteCustomerBusinessProfile

import { DeleteCustomerBusinessProfile } from '@deliverart/sdk-js-customer';

await sdk.call(new DeleteCustomerBusinessProfile('profile-123'));

Complete Usage Example

import { sdk } from './lib/sdk';
import {
  CreateCustomer,
  CreateCustomerAddress,
  CreateCustomerBusinessProfile,
  GetCustomers
} from '@deliverart/sdk-js-customer';

async function customerWorkflow() {
  // Create customer
  const customer = await sdk.call(new CreateCustomer({
    firstName: 'John',
    lastName: 'Doe',
    email: '[email protected]',
    phoneNumber: '+39123456789',
    company: '/companies/123'
  }));

  // Add delivery address
  const address = await sdk.call(new CreateCustomerAddress({
    customer: `/customers/${customer.id}`,
    street: 'Via Roma 1',
    city: 'Milano',
    postalCode: '20100',
    country: 'IT',
    location: {
      latitude: 45.464664,
      longitude: 9.188540
    }
  }));

  // Add business profile (for B2B)
  const businessProfile = await sdk.call(new CreateCustomerBusinessProfile({
    customer: `/customers/${customer.id}`,
    businessName: 'Acme Inc',
    vat: 'IT12345678901',
    billingAddress: {
      street: 'Via Business 1',
      city: 'Milano',
      postalCode: '20100',
      country: 'IT'
    },
    billingData: {
      email: '[email protected]',
      pec: '[email protected]'
    }
  }));

  // Search customers
  const customers = await sdk.call(new GetCustomers({
    query: {
      email: '[email protected]'
    }
  }));

  console.log(`Found ${customers.pagination.totalItems} customers`);
}

License

MIT

版本与发布记录

@deliverart/sdk-js-customer 共发布 324 个版本,首次发布于 2025/06/30;过去 12 个月发布了 232 个版本。

版本发布日期距今
3.0.1latest2026/11/111 天前
3.0.02026/11/092 天前
3.0.0-dev.1dev2026/11/092 天前
2.48.12026/10/2518 天前
2.48.02026/10/2319 天前
2.47.02026/10/2319 天前

关于 @deliverart/sdk-js-customer 的常见问题

@deliverart/sdk-js-customer 是什么?

Deliverart JavaScript SDK for Customer and CustomerAddress Management

如何安装 @deliverart/sdk-js-customer?

在项目目录运行 npm install @deliverart/sdk-js-customer,或使用 pnpm add / yarn add / bun add。

@deliverart/sdk-js-customer 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@deliverart/sdk-js-customer 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@deliverart/sdk-js-customer 可以商用吗?

@deliverart/sdk-js-customer 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@deliverart/sdk-js-customer 的下载量有多少?

根据 npm 官方下载统计,@deliverart/sdk-js-customer 在 2026/10/12 – 2026/11/10 这 30 天内被下载 3,725 次,日均约 124 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@deliverart/sdk-js-customer 还在维护吗?

最新版本 3.0.1 发布于 2026/11/11(1 天前);至今共发布 324 个版本,其中过去 12 个月发布了 232 个;首次发布于 2025/06/30。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。