@labdigital/commercetools-mock 1.3.2 → 1.4.0
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/dist/{index.mjs → index.cjs} +2423 -1905
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +2385 -1943
- package/dist/index.js.map +1 -1
- package/package.json +6 -7
- package/src/ctMock.ts +11 -11
- package/src/index.test.ts +1 -1
- package/src/index.ts +2 -2
- package/src/lib/haversine.test.ts +1 -1
- package/src/lib/masking.ts +1 -1
- package/src/lib/parser.ts +2 -0
- package/src/lib/predicateParser.test.ts +1 -1
- package/src/lib/predicateParser.ts +3 -4
- package/src/lib/projectionSearchFilter.test.ts +3 -3
- package/src/lib/projectionSearchFilter.ts +5 -6
- package/src/oauth/server.ts +4 -4
- package/src/priceSelector.test.ts +1 -1
- package/src/priceSelector.ts +2 -2
- package/src/product-projection-search.ts +6 -6
- package/src/projectAPI.test.ts +1 -1
- package/src/projectAPI.ts +5 -5
- package/src/repositories/abstract.ts +5 -5
- package/src/repositories/associate-role.ts +1 -1
- package/src/repositories/attribute-group.ts +1 -1
- package/src/repositories/business-unit.ts +1 -1
- package/src/repositories/cart-discount.ts +4 -4
- package/src/repositories/cart.ts +5 -5
- package/src/repositories/category.ts +4 -4
- package/src/repositories/channel.ts +4 -4
- package/src/repositories/custom-object.ts +5 -5
- package/src/repositories/customer-group.ts +4 -4
- package/src/repositories/customer.ts +4 -4
- package/src/repositories/discount-code.ts +4 -4
- package/src/repositories/errors.ts +1 -1
- package/src/repositories/extension.ts +4 -4
- package/src/repositories/helpers.ts +3 -3
- package/src/repositories/index.ts +37 -37
- package/src/repositories/inventory-entry.ts +4 -4
- package/src/repositories/my-order.ts +2 -2
- package/src/repositories/order-edit.ts +3 -3
- package/src/repositories/order.test.ts +2 -2
- package/src/repositories/order.ts +5 -5
- package/src/repositories/payment.ts +4 -4
- package/src/repositories/product-discount.ts +4 -4
- package/src/repositories/product-projection.ts +4 -4
- package/src/repositories/product-selection.ts +3 -3
- package/src/repositories/product-type.ts +3 -3
- package/src/repositories/product.ts +4 -4
- package/src/repositories/project.ts +3 -3
- package/src/repositories/quote-request.ts +2 -2
- package/src/repositories/quote.ts +2 -2
- package/src/repositories/review.ts +3 -3
- package/src/repositories/shipping-method.ts +4 -4
- package/src/repositories/shopping-list.ts +3 -3
- package/src/repositories/staged-quote.ts +2 -2
- package/src/repositories/standalone-price.ts +4 -4
- package/src/repositories/state.ts +4 -4
- package/src/repositories/store.ts +4 -4
- package/src/repositories/subscription.ts +3 -3
- package/src/repositories/tax-category.ts +3 -3
- package/src/repositories/type.ts +4 -4
- package/src/repositories/zone.ts +3 -3
- package/src/server.ts +1 -1
- package/src/services/abstract.ts +2 -2
- package/src/services/cart-discount.ts +2 -2
- package/src/services/cart.test.ts +1 -1
- package/src/services/cart.ts +4 -4
- package/src/services/category.test.ts +1 -1
- package/src/services/category.ts +2 -2
- package/src/services/channel.ts +2 -2
- package/src/services/custom-object.test.ts +2 -2
- package/src/services/custom-object.ts +3 -3
- package/src/services/customer-group.ts +2 -2
- package/src/services/customer.test.ts +1 -1
- package/src/services/customer.ts +4 -4
- package/src/services/discount-code.ts +2 -2
- package/src/services/extension.ts +2 -2
- package/src/services/index.ts +29 -29
- package/src/services/inventory-entry.test.ts +1 -1
- package/src/services/inventory-entry.ts +2 -2
- package/src/services/my-cart.test.ts +1 -1
- package/src/services/my-cart.ts +2 -2
- package/src/services/my-customer.test.ts +1 -1
- package/src/services/my-customer.ts +3 -3
- package/src/services/my-order.ts +2 -2
- package/src/services/my-payment.test.ts +1 -1
- package/src/services/my-payment.ts +2 -2
- package/src/services/order.test.ts +1 -1
- package/src/services/order.ts +3 -3
- package/src/services/payment.test.ts +1 -1
- package/src/services/payment.ts +2 -2
- package/src/services/product-discount.ts +2 -2
- package/src/services/product-projection.test.ts +2 -2
- package/src/services/product-projection.ts +3 -3
- package/src/services/product-type.test.ts +1 -1
- package/src/services/product-type.ts +2 -2
- package/src/services/product.test.ts +1 -1
- package/src/services/product.ts +2 -2
- package/src/services/project.ts +2 -2
- package/src/services/shipping-method.test.ts +1 -1
- package/src/services/shipping-method.ts +2 -2
- package/src/services/shopping-list.ts +2 -2
- package/src/services/standalone-price.test.ts +1 -1
- package/src/services/standalone-price.ts +3 -3
- package/src/services/state.test.ts +1 -1
- package/src/services/state.ts +2 -2
- package/src/services/store.test.ts +1 -1
- package/src/services/store.ts +2 -2
- package/src/services/subscription.ts +2 -2
- package/src/services/tax-category.test.ts +1 -1
- package/src/services/tax-category.ts +2 -2
- package/src/services/type.ts +2 -2
- package/src/services/zone.ts +2 -2
- package/src/storage/abstract.ts +1 -1
- package/src/storage/in-memory.ts +6 -6
- package/src/storage/index.ts +2 -2
- package/src/types.ts +2 -2
- package/dist/index.mjs.map +0 -1
- /package/dist/{index.d.mts → index.d.cts} +0 -0
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@labdigital/commercetools-mock",
|
|
3
3
|
"author": "Michael van Tellingen",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.4.0",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"main": "dist/index.
|
|
7
|
-
"module": "dist/index.
|
|
6
|
+
"main": "dist/index.cjs",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"type": "module",
|
|
8
9
|
"typings": "dist/index.d.ts",
|
|
9
10
|
"files": [
|
|
10
11
|
"dist",
|
|
@@ -12,8 +13,8 @@
|
|
|
12
13
|
],
|
|
13
14
|
"exports": {
|
|
14
15
|
".": {
|
|
15
|
-
"require": "./dist/index.
|
|
16
|
-
"import": "./dist/index.
|
|
16
|
+
"require": "./dist/index.cjs",
|
|
17
|
+
"import": "./dist/index.js",
|
|
17
18
|
"types": "./dist/index.d.ts"
|
|
18
19
|
}
|
|
19
20
|
},
|
|
@@ -39,8 +40,6 @@
|
|
|
39
40
|
"lodash.isequal": "^4.5.0",
|
|
40
41
|
"morgan": "^1.10.0",
|
|
41
42
|
"nock": "^13.3.2",
|
|
42
|
-
"perplex": "^0.11.0",
|
|
43
|
-
"pratt": "^0.7.0",
|
|
44
43
|
"supertest": "^6.3.3",
|
|
45
44
|
"uuid": "^9.0.0"
|
|
46
45
|
},
|
package/src/ctMock.ts
CHANGED
|
@@ -2,19 +2,19 @@ import nock from 'nock'
|
|
|
2
2
|
import express, { NextFunction, Request, Response } from 'express'
|
|
3
3
|
import supertest from 'supertest'
|
|
4
4
|
import morgan from 'morgan'
|
|
5
|
-
import { AbstractStorage, InMemoryStorage } from './storage'
|
|
6
|
-
import { Services } from './types'
|
|
7
|
-
import { CommercetoolsError } from './exceptions'
|
|
8
|
-
import { OAuth2Server } from './oauth/server'
|
|
9
|
-
import { ProjectAPI } from './projectAPI'
|
|
10
|
-
import { copyHeaders } from './lib/proxy'
|
|
11
|
-
import { DEFAULT_API_HOSTNAME, DEFAULT_AUTH_HOSTNAME } from './constants'
|
|
5
|
+
import { AbstractStorage, InMemoryStorage } from './storage/index.js'
|
|
6
|
+
import { Services } from './types.js'
|
|
7
|
+
import { CommercetoolsError } from './exceptions.js'
|
|
8
|
+
import { OAuth2Server } from './oauth/server.js'
|
|
9
|
+
import { ProjectAPI } from './projectAPI.js'
|
|
10
|
+
import { copyHeaders } from './lib/proxy.js'
|
|
11
|
+
import { DEFAULT_API_HOSTNAME, DEFAULT_AUTH_HOSTNAME } from './constants.js'
|
|
12
12
|
|
|
13
13
|
// Services
|
|
14
|
-
import { ProjectService } from './services/project'
|
|
15
|
-
import { createRepositories, RepositoryMap } from './repositories'
|
|
16
|
-
import { createServices } from './services'
|
|
17
|
-
import { ProjectRepository } from 'repositories/project'
|
|
14
|
+
import { ProjectService } from './services/project.js'
|
|
15
|
+
import { createRepositories, RepositoryMap } from './repositories/index.js'
|
|
16
|
+
import { createServices } from './services/index.js'
|
|
17
|
+
import { ProjectRepository } from './repositories/project.js'
|
|
18
18
|
|
|
19
19
|
export type CommercetoolsMockOptions = {
|
|
20
20
|
validateCredentials: boolean
|
package/src/index.test.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type InvalidTokenError } from '@commercetools/platform-sdk'
|
|
2
|
-
import { CommercetoolsMock } from './index'
|
|
2
|
+
import { CommercetoolsMock } from './index.js'
|
|
3
3
|
import { afterEach, beforeEach, expect, test } from 'vitest'
|
|
4
4
|
import nock from 'nock'
|
|
5
5
|
import got from 'got'
|
package/src/index.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CommercetoolsMock, CommercetoolsMockOptions } from './ctMock'
|
|
2
|
-
import { getBaseResourceProperties } from './helpers'
|
|
1
|
+
import { CommercetoolsMock, CommercetoolsMockOptions } from './ctMock.js'
|
|
2
|
+
import { getBaseResourceProperties } from './helpers.js'
|
|
3
3
|
|
|
4
4
|
export {
|
|
5
5
|
CommercetoolsMock,
|
package/src/lib/masking.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { VariableMap } from '@commercetools/platform-sdk'
|
|
2
2
|
import { describe, expect, test } from 'vitest'
|
|
3
|
-
import { parseQueryExpression, PredicateError } from './predicateParser'
|
|
3
|
+
import { parseQueryExpression, PredicateError } from './predicateParser.js'
|
|
4
4
|
|
|
5
5
|
describe('Predicate filter', () => {
|
|
6
6
|
const exampleObject = {
|
|
@@ -4,9 +4,8 @@
|
|
|
4
4
|
*
|
|
5
5
|
* See https://docs.commercetools.com/api/predicates/query
|
|
6
6
|
*/
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import { haversineDistance } from './haversine'
|
|
7
|
+
import { haversineDistance } from './haversine.js'
|
|
8
|
+
import { Lexer, Parser, type ITokenPosition } from './parser.js'
|
|
10
9
|
|
|
11
10
|
export class PredicateError {
|
|
12
11
|
message: string
|
|
@@ -104,7 +103,7 @@ const resolveValue = (obj: any, val: TypeSymbol): any => {
|
|
|
104
103
|
}
|
|
105
104
|
|
|
106
105
|
const getLexer = (value: string) =>
|
|
107
|
-
new
|
|
106
|
+
new Lexer(value)
|
|
108
107
|
|
|
109
108
|
.token('AND', /and(?![-_a-z0-9]+)/i)
|
|
110
109
|
.token('OR', /or(?![-_a-z0-9]+)/i)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { ProductProjection } from '@commercetools/platform-sdk'
|
|
2
2
|
import { describe, expect, test } from 'vitest'
|
|
3
|
-
import { cloneObject } from '../helpers'
|
|
4
|
-
import { applyPriceSelector } from '../priceSelector'
|
|
5
|
-
import { parseFilterExpression } from './projectionSearchFilter'
|
|
3
|
+
import { cloneObject } from '../helpers.js'
|
|
4
|
+
import { applyPriceSelector } from '../priceSelector.js'
|
|
5
|
+
import { parseFilterExpression } from './projectionSearchFilter.js'
|
|
6
6
|
|
|
7
7
|
describe('Search filter', () => {
|
|
8
8
|
const exampleProduct: ProductProjection = {
|
|
@@ -3,10 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import type { ProductProjection, ProductVariant } from '@commercetools/platform-sdk'
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import type { Writable } from '../types'
|
|
6
|
+
import { nestedLookup } from '../helpers.js'
|
|
7
|
+
import type { Writable } from '../types.js'
|
|
8
|
+
import { Lexer, Parser } from './parser.js'
|
|
10
9
|
|
|
11
10
|
type MatchFunc = (target: any) => boolean
|
|
12
11
|
|
|
@@ -72,7 +71,7 @@ export const parseFilterExpression = (
|
|
|
72
71
|
}
|
|
73
72
|
|
|
74
73
|
const getLexer = (value: string) =>
|
|
75
|
-
new
|
|
74
|
+
new Lexer(value)
|
|
76
75
|
.token('MISSING', /missing(?![-_a-z0-9]+)/i)
|
|
77
76
|
.token('EXISTS', /exists(?![-_a-z0-9]+)/i)
|
|
78
77
|
.token('RANGE', /range(?![-_a-z0-9]+)/i)
|
|
@@ -211,7 +210,7 @@ const parseFilter = (filter: string): ExpressionSet => {
|
|
|
211
210
|
// Return a list of functions which matches the ranges. These functions
|
|
212
211
|
// are processed as an OR clause
|
|
213
212
|
return ranges.map((range: any) => {
|
|
214
|
-
let func
|
|
213
|
+
let func: (obj: any) => boolean
|
|
215
214
|
|
|
216
215
|
if (range.start !== null && range.stop !== null) {
|
|
217
216
|
func = (obj: any): boolean => obj >= range.start && obj <= range.stop
|
package/src/oauth/server.ts
CHANGED
|
@@ -4,10 +4,10 @@ import express, { type NextFunction, type Request, type Response } from 'express
|
|
|
4
4
|
import {
|
|
5
5
|
InvalidTokenError,
|
|
6
6
|
} from '@commercetools/platform-sdk'
|
|
7
|
-
import { CommercetoolsError, InvalidRequestError } from '../exceptions'
|
|
8
|
-
import { InvalidClientError, UnsupportedGrantType } from './errors'
|
|
9
|
-
import { OAuth2Store } from './store'
|
|
10
|
-
import { getBearerToken } from './helpers'
|
|
7
|
+
import { CommercetoolsError, InvalidRequestError } from '../exceptions.js'
|
|
8
|
+
import { InvalidClientError, UnsupportedGrantType } from './errors.js'
|
|
9
|
+
import { OAuth2Store } from './store.js'
|
|
10
|
+
import { getBearerToken } from './helpers.js'
|
|
11
11
|
|
|
12
12
|
export class OAuth2Server {
|
|
13
13
|
store: OAuth2Store
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ProductProjection } from '@commercetools/platform-sdk'
|
|
2
2
|
import { beforeEach, describe, expect, test } from 'vitest'
|
|
3
|
-
import { applyPriceSelector } from './priceSelector'
|
|
3
|
+
import { applyPriceSelector } from './priceSelector.js'
|
|
4
4
|
|
|
5
5
|
describe('priceSelector', () => {
|
|
6
6
|
let product: ProductProjection
|
package/src/priceSelector.ts
CHANGED
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
ProductProjection,
|
|
5
5
|
ProductVariant,
|
|
6
6
|
} from '@commercetools/platform-sdk'
|
|
7
|
-
import { CommercetoolsError } from './exceptions'
|
|
8
|
-
import type { Writable } from './types'
|
|
7
|
+
import { CommercetoolsError } from './exceptions.js'
|
|
8
|
+
import type { Writable } from './types.js'
|
|
9
9
|
|
|
10
10
|
export type PriceSelector = {
|
|
11
11
|
currency?: string
|
|
@@ -9,8 +9,8 @@ import type {
|
|
|
9
9
|
RangeFacetResult,
|
|
10
10
|
TermFacetResult,
|
|
11
11
|
} from '@commercetools/platform-sdk'
|
|
12
|
-
import { CommercetoolsError } from './exceptions'
|
|
13
|
-
import { nestedLookup } from './helpers'
|
|
12
|
+
import { CommercetoolsError } from './exceptions.js'
|
|
13
|
+
import { nestedLookup } from './helpers.js'
|
|
14
14
|
import {
|
|
15
15
|
FilterExpression,
|
|
16
16
|
RangeExpression,
|
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
getVariants,
|
|
19
19
|
parseFilterExpression,
|
|
20
20
|
resolveVariantValue,
|
|
21
|
-
} from './lib/projectionSearchFilter'
|
|
22
|
-
import { applyPriceSelector } from './priceSelector'
|
|
23
|
-
import { AbstractStorage } from './storage'
|
|
24
|
-
import type { Writable } from './types'
|
|
21
|
+
} from './lib/projectionSearchFilter.js'
|
|
22
|
+
import { applyPriceSelector } from './priceSelector.js'
|
|
23
|
+
import { AbstractStorage } from './storage/index.js'
|
|
24
|
+
import type { Writable } from './types.js'
|
|
25
25
|
|
|
26
26
|
export type ProductProjectionSearchParams = {
|
|
27
27
|
fuzzy?: boolean
|
package/src/projectAPI.test.ts
CHANGED
package/src/projectAPI.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { ResourceMap, ResourceType } from './types'
|
|
1
|
+
import { getBaseResourceProperties } from './helpers.js'
|
|
2
|
+
import { GetParams } from './repositories/abstract.js'
|
|
3
|
+
import { RepositoryMap } from './repositories/index.js'
|
|
4
|
+
import { AbstractStorage } from './storage/index.js'
|
|
5
|
+
import { ResourceMap, ResourceType } from './types.js'
|
|
6
6
|
|
|
7
7
|
export class ProjectAPI {
|
|
8
8
|
private projectKey: string
|
|
@@ -5,11 +5,11 @@ import type {
|
|
|
5
5
|
UpdateAction,
|
|
6
6
|
} from '@commercetools/platform-sdk'
|
|
7
7
|
import deepEqual from 'deep-equal'
|
|
8
|
-
import { CommercetoolsError } from '../exceptions'
|
|
9
|
-
import { cloneObject } from '../helpers'
|
|
10
|
-
import { AbstractStorage } from '../storage'
|
|
11
|
-
import { ResourceMap, ResourceType, ShallowWritable } from './../types'
|
|
12
|
-
import { checkConcurrentModification } from './errors'
|
|
8
|
+
import { CommercetoolsError } from '../exceptions.js'
|
|
9
|
+
import { cloneObject } from '../helpers.js'
|
|
10
|
+
import { AbstractStorage } from '../storage/index.js'
|
|
11
|
+
import { ResourceMap, ResourceType, ShallowWritable } from './../types.js'
|
|
12
|
+
import { checkConcurrentModification } from './errors.js'
|
|
13
13
|
|
|
14
14
|
export type QueryParams = {
|
|
15
15
|
expand?: string[]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AssociateRole } from '@commercetools/platform-sdk'
|
|
2
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
2
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
3
3
|
|
|
4
4
|
export class AssociateRoleRepository extends AbstractResourceRepository<'associate-role'> {
|
|
5
5
|
getTypeId() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AttributeGroup } from '@commercetools/platform-sdk'
|
|
2
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
2
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
3
3
|
|
|
4
4
|
export class AttributeGroupRepository extends AbstractResourceRepository<'attribute-group'> {
|
|
5
5
|
getTypeId() {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BusinessUnit } from '@commercetools/platform-sdk'
|
|
2
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
2
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
3
3
|
|
|
4
4
|
export class BusinessUnitRepository extends AbstractResourceRepository<'business-unit'> {
|
|
5
5
|
getTypeId() {
|
|
@@ -15,13 +15,13 @@ import type {
|
|
|
15
15
|
CartDiscountValueGiftLineItem,
|
|
16
16
|
CartDiscountValueRelative,
|
|
17
17
|
} from '@commercetools/platform-sdk'
|
|
18
|
-
import
|
|
19
|
-
import {
|
|
20
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
18
|
+
import { getBaseResourceProperties } from '../helpers.js'
|
|
19
|
+
import type { Writable } from '../types.js'
|
|
20
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
21
21
|
import {
|
|
22
22
|
createTypedMoney,
|
|
23
23
|
getStoreKeyReference,
|
|
24
|
-
} from './helpers'
|
|
24
|
+
} from './helpers.js'
|
|
25
25
|
|
|
26
26
|
export class CartDiscountRepository extends AbstractResourceRepository<'cart-discount'> {
|
|
27
27
|
getTypeId() {
|
package/src/repositories/cart.ts
CHANGED
|
@@ -24,11 +24,11 @@ import type {
|
|
|
24
24
|
ProductVariant,
|
|
25
25
|
} from '@commercetools/platform-sdk'
|
|
26
26
|
import { v4 as uuidv4 } from 'uuid'
|
|
27
|
-
import { CommercetoolsError } from '../exceptions'
|
|
28
|
-
import { getBaseResourceProperties } from '../helpers'
|
|
29
|
-
import type { Writable } from '../types'
|
|
30
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
31
|
-
import { createAddress, createCustomFields } from './helpers'
|
|
27
|
+
import { CommercetoolsError } from '../exceptions.js'
|
|
28
|
+
import { getBaseResourceProperties } from '../helpers.js'
|
|
29
|
+
import type { Writable } from '../types.js'
|
|
30
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
31
|
+
import { createAddress, createCustomFields } from './helpers.js'
|
|
32
32
|
|
|
33
33
|
export class CartRepository extends AbstractResourceRepository<'cart'> {
|
|
34
34
|
getTypeId() {
|
|
@@ -14,10 +14,10 @@ import type {
|
|
|
14
14
|
CategorySetMetaTitleAction,
|
|
15
15
|
} from '@commercetools/platform-sdk'
|
|
16
16
|
import { v4 as uuidv4 } from 'uuid'
|
|
17
|
-
import { getBaseResourceProperties } from '../helpers'
|
|
18
|
-
import type { Writable } from '../types'
|
|
19
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
20
|
-
import { createCustomFields } from './helpers'
|
|
17
|
+
import { getBaseResourceProperties } from '../helpers.js'
|
|
18
|
+
import type { Writable } from '../types.js'
|
|
19
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
20
|
+
import { createCustomFields } from './helpers.js'
|
|
21
21
|
|
|
22
22
|
export class CategoryRepository extends AbstractResourceRepository<'category'> {
|
|
23
23
|
getTypeId() {
|
|
@@ -10,10 +10,10 @@ import type {
|
|
|
10
10
|
ChannelSetGeoLocationAction,
|
|
11
11
|
ChannelUpdateAction,
|
|
12
12
|
} from '@commercetools/platform-sdk'
|
|
13
|
-
import { getBaseResourceProperties } from '../helpers'
|
|
14
|
-
import type { Writable } from '../types'
|
|
15
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
16
|
-
import { createAddress, createCustomFields } from './helpers'
|
|
13
|
+
import { getBaseResourceProperties } from '../helpers.js'
|
|
14
|
+
import type { Writable } from '../types.js'
|
|
15
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
16
|
+
import { createAddress, createCustomFields } from './helpers.js'
|
|
17
17
|
|
|
18
18
|
export class ChannelRepository extends AbstractResourceRepository<'channel'> {
|
|
19
19
|
getTypeId() {
|
|
@@ -3,11 +3,11 @@ import type {
|
|
|
3
3
|
CustomObjectDraft,
|
|
4
4
|
InvalidOperationError,
|
|
5
5
|
} from '@commercetools/platform-sdk'
|
|
6
|
-
import { CommercetoolsError } from '../exceptions'
|
|
7
|
-
import { cloneObject, getBaseResourceProperties } from '../helpers'
|
|
8
|
-
import type { Writable } from '../types'
|
|
9
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
10
|
-
import { checkConcurrentModification } from './errors'
|
|
6
|
+
import { CommercetoolsError } from '../exceptions.js'
|
|
7
|
+
import { cloneObject, getBaseResourceProperties } from '../helpers.js'
|
|
8
|
+
import type { Writable } from '../types.js'
|
|
9
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
10
|
+
import { checkConcurrentModification } from './errors.js'
|
|
11
11
|
|
|
12
12
|
export class CustomObjectRepository extends AbstractResourceRepository<'key-value-document'> {
|
|
13
13
|
getTypeId() {
|
|
@@ -6,10 +6,10 @@ import type {
|
|
|
6
6
|
CustomerGroupSetCustomTypeAction,
|
|
7
7
|
CustomerGroupSetKeyAction,
|
|
8
8
|
} from '@commercetools/platform-sdk'
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
12
|
-
import { createCustomFields } from './helpers'
|
|
9
|
+
import { getBaseResourceProperties } from '../helpers.js'
|
|
10
|
+
import type { Writable } from '../types.js'
|
|
11
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
12
|
+
import { createCustomFields } from './helpers.js'
|
|
13
13
|
|
|
14
14
|
export class CustomerGroupRepository extends AbstractResourceRepository<'customer-group'> {
|
|
15
15
|
getTypeId() {
|
|
@@ -6,10 +6,10 @@ import type {
|
|
|
6
6
|
InvalidInputError,
|
|
7
7
|
InvalidJsonInputError,
|
|
8
8
|
} from '@commercetools/platform-sdk'
|
|
9
|
-
import type { Writable } from 'types'
|
|
10
|
-
import { CommercetoolsError } from '../exceptions'
|
|
11
|
-
import { getBaseResourceProperties } from '../helpers'
|
|
12
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
9
|
+
import type { Writable } from '../types.js'
|
|
10
|
+
import { CommercetoolsError } from '../exceptions.js'
|
|
11
|
+
import { getBaseResourceProperties } from '../helpers.js'
|
|
12
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
13
13
|
|
|
14
14
|
export class CustomerRepository extends AbstractResourceRepository<'customer'> {
|
|
15
15
|
getTypeId() {
|
|
@@ -16,10 +16,10 @@ import type {
|
|
|
16
16
|
DiscountCodeSetValidUntilAction,
|
|
17
17
|
DiscountCodeUpdateAction,
|
|
18
18
|
} from '@commercetools/platform-sdk'
|
|
19
|
-
import { getBaseResourceProperties } from '../helpers'
|
|
20
|
-
import type { Writable } from '../types'
|
|
21
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
22
|
-
import { createCustomFields } from './helpers'
|
|
19
|
+
import { getBaseResourceProperties } from '../helpers.js'
|
|
20
|
+
import type { Writable } from '../types.js'
|
|
21
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
22
|
+
import { createCustomFields } from './helpers.js'
|
|
23
23
|
|
|
24
24
|
export class DiscountCodeRepository extends AbstractResourceRepository<'discount-code'> {
|
|
25
25
|
getTypeId() {
|
|
@@ -7,10 +7,10 @@ import type {
|
|
|
7
7
|
ExtensionSetTimeoutInMsAction,
|
|
8
8
|
ExtensionUpdateAction,
|
|
9
9
|
} from '@commercetools/platform-sdk'
|
|
10
|
-
import { getBaseResourceProperties } from '../helpers'
|
|
11
|
-
import { maskSecretValue } from '../lib/masking'
|
|
12
|
-
import type { Writable } from '../types'
|
|
13
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
10
|
+
import { getBaseResourceProperties } from '../helpers.js'
|
|
11
|
+
import { maskSecretValue } from '../lib/masking.js'
|
|
12
|
+
import type { Writable } from '../types.js'
|
|
13
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
14
14
|
|
|
15
15
|
export class ExtensionRepository extends AbstractResourceRepository<'extension'> {
|
|
16
16
|
getTypeId() {
|
|
@@ -22,9 +22,9 @@ import type {
|
|
|
22
22
|
} from '@commercetools/platform-sdk'
|
|
23
23
|
import type { Request } from 'express'
|
|
24
24
|
import { v4 as uuidv4 } from 'uuid'
|
|
25
|
-
import { CommercetoolsError } from '../exceptions'
|
|
26
|
-
import { AbstractStorage } from '../storage'
|
|
27
|
-
import { type RepositoryContext } from './abstract'
|
|
25
|
+
import { CommercetoolsError } from '../exceptions.js'
|
|
26
|
+
import { AbstractStorage } from '../storage/index.js'
|
|
27
|
+
import { type RepositoryContext } from './abstract.js'
|
|
28
28
|
|
|
29
29
|
export const createAddress = (
|
|
30
30
|
base: BaseAddress | undefined,
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { AbstractStorage } from '../storage'
|
|
2
|
-
import { AssociateRoleRepository } from './associate-role'
|
|
3
|
-
import { AttributeGroupRepository } from './attribute-group'
|
|
4
|
-
import { BusinessUnitRepository } from './business-unit'
|
|
5
|
-
import { CartRepository } from './cart'
|
|
6
|
-
import { CartDiscountRepository } from './cart-discount'
|
|
7
|
-
import { CategoryRepository } from './category'
|
|
8
|
-
import { ChannelRepository } from './channel'
|
|
9
|
-
import { CustomObjectRepository } from './custom-object'
|
|
10
|
-
import { CustomerRepository } from './customer'
|
|
11
|
-
import { CustomerGroupRepository } from './customer-group'
|
|
12
|
-
import { DiscountCodeRepository } from './discount-code'
|
|
13
|
-
import { ExtensionRepository } from './extension'
|
|
14
|
-
import { InventoryEntryRepository } from './inventory-entry'
|
|
15
|
-
import { MyOrderRepository } from './my-order'
|
|
16
|
-
import { OrderRepository } from './order'
|
|
17
|
-
import { OrderEditRepository } from './order-edit'
|
|
18
|
-
import { PaymentRepository } from './payment'
|
|
19
|
-
import { ProductRepository } from './product'
|
|
20
|
-
import { ProductDiscountRepository } from './product-discount'
|
|
21
|
-
import { ProductProjectionRepository } from './product-projection'
|
|
22
|
-
import { ProductSelectionRepository } from './product-selection'
|
|
23
|
-
import { ProductTypeRepository } from './product-type'
|
|
24
|
-
import { ProjectRepository } from './project'
|
|
25
|
-
import { QuoteRepository } from './quote'
|
|
26
|
-
import { QuoteRequestRepository } from './quote-request'
|
|
27
|
-
import { ReviewRepository } from './review'
|
|
28
|
-
import { ShippingMethodRepository } from './shipping-method'
|
|
29
|
-
import { ShoppingListRepository } from './shopping-list'
|
|
30
|
-
import { StagedQuoteRepository } from './staged-quote'
|
|
31
|
-
import { StandAlonePriceRepository } from './standalone-price'
|
|
32
|
-
import { StateRepository } from './state'
|
|
33
|
-
import { StoreRepository } from './store'
|
|
34
|
-
import { SubscriptionRepository } from './subscription'
|
|
35
|
-
import { TaxCategoryRepository } from './tax-category'
|
|
36
|
-
import { TypeRepository } from './type'
|
|
37
|
-
import { ZoneRepository } from './zone'
|
|
1
|
+
import { AbstractStorage } from '../storage/index.js'
|
|
2
|
+
import { AssociateRoleRepository } from './associate-role.js'
|
|
3
|
+
import { AttributeGroupRepository } from './attribute-group.js'
|
|
4
|
+
import { BusinessUnitRepository } from './business-unit.js'
|
|
5
|
+
import { CartRepository } from './cart.js'
|
|
6
|
+
import { CartDiscountRepository } from './cart-discount.js'
|
|
7
|
+
import { CategoryRepository } from './category.js'
|
|
8
|
+
import { ChannelRepository } from './channel.js'
|
|
9
|
+
import { CustomObjectRepository } from './custom-object.js'
|
|
10
|
+
import { CustomerRepository } from './customer.js'
|
|
11
|
+
import { CustomerGroupRepository } from './customer-group.js'
|
|
12
|
+
import { DiscountCodeRepository } from './discount-code.js'
|
|
13
|
+
import { ExtensionRepository } from './extension.js'
|
|
14
|
+
import { InventoryEntryRepository } from './inventory-entry.js'
|
|
15
|
+
import { MyOrderRepository } from './my-order.js'
|
|
16
|
+
import { OrderRepository } from './order.js'
|
|
17
|
+
import { OrderEditRepository } from './order-edit.js'
|
|
18
|
+
import { PaymentRepository } from './payment.js'
|
|
19
|
+
import { ProductRepository } from './product.js'
|
|
20
|
+
import { ProductDiscountRepository } from './product-discount.js'
|
|
21
|
+
import { ProductProjectionRepository } from './product-projection.js'
|
|
22
|
+
import { ProductSelectionRepository } from './product-selection.js'
|
|
23
|
+
import { ProductTypeRepository } from './product-type.js'
|
|
24
|
+
import { ProjectRepository } from './project.js'
|
|
25
|
+
import { QuoteRepository } from './quote.js'
|
|
26
|
+
import { QuoteRequestRepository } from './quote-request.js'
|
|
27
|
+
import { ReviewRepository } from './review.js'
|
|
28
|
+
import { ShippingMethodRepository } from './shipping-method.js'
|
|
29
|
+
import { ShoppingListRepository } from './shopping-list.js'
|
|
30
|
+
import { StagedQuoteRepository } from './staged-quote.js'
|
|
31
|
+
import { StandAlonePriceRepository } from './standalone-price.js'
|
|
32
|
+
import { StateRepository } from './state.js'
|
|
33
|
+
import { StoreRepository } from './store.js'
|
|
34
|
+
import { SubscriptionRepository } from './subscription.js'
|
|
35
|
+
import { TaxCategoryRepository } from './tax-category.js'
|
|
36
|
+
import { TypeRepository } from './type.js'
|
|
37
|
+
import { ZoneRepository } from './zone.js'
|
|
38
38
|
|
|
39
39
|
export type RepositoryMap = ReturnType<typeof createRepositories>
|
|
40
40
|
|
|
@@ -7,10 +7,10 @@ import type {
|
|
|
7
7
|
InventoryEntrySetExpectedDeliveryAction,
|
|
8
8
|
InventoryEntrySetRestockableInDaysAction,
|
|
9
9
|
} from '@commercetools/platform-sdk'
|
|
10
|
-
import { getBaseResourceProperties } from '../helpers'
|
|
11
|
-
import type { Writable } from '../types'
|
|
12
|
-
import { AbstractResourceRepository, type RepositoryContext } from './abstract'
|
|
13
|
-
import { createCustomFields } from './helpers'
|
|
10
|
+
import { getBaseResourceProperties } from '../helpers.js'
|
|
11
|
+
import type { Writable } from '../types.js'
|
|
12
|
+
import { AbstractResourceRepository, type RepositoryContext } from './abstract.js'
|
|
13
|
+
import { createCustomFields } from './helpers.js'
|
|
14
14
|
|
|
15
15
|
export class InventoryEntryRepository extends AbstractResourceRepository<'inventory-entry'> {
|
|
16
16
|
getTypeId() {
|
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
Order,
|
|
5
5
|
} from '@commercetools/platform-sdk'
|
|
6
6
|
import assert from 'assert'
|
|
7
|
-
import { type RepositoryContext } from './abstract'
|
|
8
|
-
import { OrderRepository } from './order'
|
|
7
|
+
import { type RepositoryContext } from './abstract.js'
|
|
8
|
+
import { OrderRepository } from './order.js'
|
|
9
9
|
|
|
10
10
|
export class MyOrderRepository extends OrderRepository {
|
|
11
11
|
create(context: RepositoryContext, draft: MyOrderFromCartDraft): Order {
|
|
@@ -4,9 +4,9 @@ import type {
|
|
|
4
4
|
OrderEditResult,
|
|
5
5
|
OrderEditUpdateAction,
|
|
6
6
|
} from '@commercetools/platform-sdk'
|
|
7
|
-
import { getBaseResourceProperties } from '../helpers'
|
|
8
|
-
import type { Writable } from '../types'
|
|
9
|
-
import { AbstractResourceRepository, RepositoryContext } from './abstract'
|
|
7
|
+
import { getBaseResourceProperties } from '../helpers.js'
|
|
8
|
+
import type { Writable } from '../types.js'
|
|
9
|
+
import { AbstractResourceRepository, RepositoryContext } from './abstract.js'
|
|
10
10
|
|
|
11
11
|
export class OrderEditRepository extends AbstractResourceRepository<'order-edit'> {
|
|
12
12
|
getTypeId() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Cart, OrderImportDraft } from '@commercetools/platform-sdk'
|
|
2
2
|
import { describe, expect, test } from 'vitest'
|
|
3
|
-
import { InMemoryStorage } from '../storage'
|
|
4
|
-
import { OrderRepository } from './order'
|
|
3
|
+
import { InMemoryStorage } from '../storage/index.js'
|
|
4
|
+
import { OrderRepository } from './order.js'
|
|
5
5
|
|
|
6
6
|
describe('Order repository', () => {
|
|
7
7
|
const storage = new InMemoryStorage()
|