@deliverart/sdk-js-point-of-sale 0.0.8 → 0.1.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.
@@ -1,14 +1,18 @@
1
1
  import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
2
  import { z } from 'zod'
3
3
 
4
- import { PointOfSaleDetails, pointOfSaleDetailsSchema } from '../models'
4
+ import { pointOfSaleDetailsSchema } from '../models'
5
5
 
6
6
  export const getPointOfSaleDetailsInputSchema = z.undefined()
7
+ export type GetPointOfSaleDetailsInput = z.input<typeof getPointOfSaleDetailsInputSchema>
7
8
 
8
9
  export const getPointOfSaleDetailsResponseSchema = pointOfSaleDetailsSchema
9
- export type GetPointOfSaleDetailsResponse = PointOfSaleDetails
10
+ export type GetPointOfSaleDetailsResponse = z.infer<typeof getPointOfSaleDetailsResponseSchema>
10
11
 
11
- export class GetPointOfSaleDetails extends AbstractApiRequest<void, GetPointOfSaleDetailsResponse> {
12
+ export class GetPointOfSaleDetails extends AbstractApiRequest<
13
+ typeof getPointOfSaleDetailsInputSchema,
14
+ typeof getPointOfSaleDetailsResponseSchema
15
+ > {
12
16
  readonly method = 'GET'
13
17
  readonly contentType = 'application/json'
14
18
  readonly accept = 'application/json'
@@ -20,7 +24,7 @@ export class GetPointOfSaleDetails extends AbstractApiRequest<void, GetPointOfSa
20
24
  private readonly pointOfSaleId: string
21
25
 
22
26
  constructor(pointOfSaleId: string) {
23
- super()
27
+ super(undefined)
24
28
  this.pointOfSaleId = pointOfSaleId
25
29
  }
26
30
 
@@ -3,35 +3,24 @@ import {
3
3
  createPaginatedSchema,
4
4
  Paginated,
5
5
  responseToPagination,
6
- sortDirSchema,
7
6
  } from '@deliverart/sdk-js-global-types'
8
7
  import { AxiosResponse } from 'axios'
9
8
  import { z } from 'zod'
10
9
 
11
- import { PointOfSale, pointOfSaleSchema } from '../models'
12
- import { pointOfSaleOpeningStatusSchema } from '../types'
13
-
14
- export const getPointOfSalesQuerySchema = z.object({
15
- name: z.string().optional(),
16
- openingStatus: pointOfSaleOpeningStatusSchema.optional(),
17
- 'integrationActivationRequests.connectionId': z.string().optional(),
18
- 'address.city': z.string().optional(),
19
- 'address.postalCode': z.string().optional(),
20
- 'order[name]': sortDirSchema.optional(),
21
- 'order[createdAt]': sortDirSchema.optional(),
22
- 'order[updatedAt]': sortDirSchema.optional(),
23
- page: z.coerce.number().optional(),
24
- })
10
+ import { PointOfSale, pointOfSaleSchema, pointOfSalesQuerySchema } from '../models'
11
+
12
+ export const getPointOfSalesQuerySchema = pointOfSalesQuerySchema
25
13
  export type GetPointOfSalesQueryParams = z.infer<typeof getPointOfSalesQuerySchema>
26
14
 
15
+ export const getPointOfSalesInputSchema = z.undefined()
16
+ export type GetPointOfSalesInput = z.input<typeof getPointOfSalesInputSchema>
17
+
27
18
  export const getPointOfSalesResponseSchema = createPaginatedSchema(pointOfSaleSchema)
28
19
  export type GetPointOfSalesResponse = z.infer<typeof getPointOfSalesResponseSchema>
29
20
 
30
- export const getPointOfSalesInputSchema = z.undefined()
31
-
32
21
  export class GetPointOfSales extends AbstractApiRequest<
33
- void,
34
- GetPointOfSalesResponse,
22
+ typeof getPointOfSalesInputSchema,
23
+ typeof getPointOfSalesResponseSchema,
35
24
  GetPointOfSalesQueryParams
36
25
  > {
37
26
  readonly method = 'GET'
@@ -1,17 +1,17 @@
1
1
  import { AbstractApiRequest } from '@deliverart/sdk-js-core'
2
2
  import { z } from 'zod'
3
3
 
4
- import { PointOfSaleDetails, pointOfSaleDetailsSchema, writablePointOfSaleSchema } from '../models'
4
+ import { pointOfSaleDetailsSchema, writablePointOfSaleSchema } from '../models'
5
5
 
6
6
  export const updatePointOfSaleInputSchema = writablePointOfSaleSchema.partial()
7
- export type UpdatePointOfSaleInput = z.infer<typeof updatePointOfSaleInputSchema>
7
+ export type UpdatePointOfSaleInput = z.input<typeof updatePointOfSaleInputSchema>
8
8
 
9
9
  export const updatePointOfSaleResponseSchema = pointOfSaleDetailsSchema
10
- export type UpdatePointOfSaleResponse = PointOfSaleDetails
10
+ export type UpdatePointOfSaleResponse = z.infer<typeof updatePointOfSaleResponseSchema>
11
11
 
12
12
  export class UpdatePointOfSale extends AbstractApiRequest<
13
- UpdatePointOfSaleInput,
14
- UpdatePointOfSaleResponse
13
+ typeof updatePointOfSaleInputSchema,
14
+ typeof updatePointOfSaleResponseSchema
15
15
  > {
16
16
  readonly method = 'PATCH'
17
17
  readonly contentType = 'application/merge-patch+json'
package/src/types.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { iriNullableSchema, iriSchema } from '@deliverart/sdk-js-global-types'
1
2
  import { z } from 'zod'
2
3
 
3
4
  export const pointOfSaleOpeningStatuses = ['OPEN', 'CLOSED'] as const
@@ -12,31 +13,8 @@ export const pointOfSaleUserRoles = ['ROLE_ADMIN', 'ROLE_READER'] as const
12
13
  export const pointOfSaleUserRoleSchema = z.enum(pointOfSaleUserRoles)
13
14
  export type PointOfSaleUserRole = z.infer<typeof pointOfSaleUserRoleSchema>
14
15
 
15
- export const pointOfSalePathSchema = z
16
- .string()
17
- .refine(
18
- val =>
19
- /^\/point_of_sales\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(
20
- val,
21
- ),
22
- {
23
- message: 'Invalid point of sale path format',
24
- },
25
- )
26
- export type PointOfSalePath = z.infer<typeof pointOfSalePathSchema>
16
+ export const pointOfSaleIriSchema = iriSchema('/customers/:id')
17
+ export type PointOfSaleIri = z.infer<typeof pointOfSaleIriSchema>
27
18
 
28
- export const pointOfSaleNullablePathSchema = z
29
- .string()
30
- .nullable()
31
- .refine(
32
- val => {
33
- if (!val) return true
34
- return /^\/point_of_sales\/[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/.test(
35
- val,
36
- )
37
- },
38
- {
39
- message: 'Invalid point of sale path format',
40
- },
41
- )
42
- export type PointOfSaleNullablePath = z.infer<typeof pointOfSaleNullablePathSchema>
19
+ export const pointOfSaleNullableIriSchema = iriNullableSchema('/customers/:id')
20
+ export type PointOfSaleNullableIri = z.infer<typeof pointOfSaleNullableIriSchema>