@cinerino/sdk 16.0.1 → 16.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.
@@ -0,0 +1,24 @@
1
+ import { factory } from '../../factory';
2
+ export interface IFindParams {
3
+ /**
4
+ * max: 100
5
+ */
6
+ limit: number;
7
+ page: number;
8
+ id?: {
9
+ /**
10
+ * IDリストを最大10件まで指定可能
11
+ */
12
+ $in?: string[];
13
+ };
14
+ identifier?: {
15
+ /**
16
+ * コードリストを最大10件まで指定可能
17
+ */
18
+ $in?: string[];
19
+ };
20
+ }
21
+ export type IUnitPriceSpecificationAsFindResult = Pick<factory.unitPriceOffer.IUnitPriceOfferPriceSpecification, 'accounting' | 'price' | 'referenceQuantity'>;
22
+ export type IUnitPriceOfferAsFindResult = Pick<factory.unitPriceOffer.IUnitPriceOffer, 'id' | 'identifier' | 'alternateName' | 'name' | 'color'> & {
23
+ priceSpecification: IUnitPriceSpecificationAsFindResult;
24
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,24 +1,14 @@
1
1
  import { factory } from '../factory';
2
2
  import { Service } from '../service';
3
- export interface IProjectionSearchConditions {
4
- $projection?: {
5
- [key in keyof factory.unitPriceOffer.IUnitPriceOffer]?: 0 | 1;
6
- };
7
- }
8
- export type IUnitPriceOfferAsSearchResult = factory.unitPriceOffer.IUnitPriceOffer & {
9
- offerIndex?: number;
10
- parentOffer?: {
11
- id?: string;
12
- };
13
- };
3
+ import { IFindParams, IUnitPriceOfferAsFindResult } from './offer/factory';
14
4
  /**
15
5
  * 単価オファーサービス
16
6
  */
17
7
  export declare class OfferService extends Service {
18
8
  /**
19
- * オファー検索
9
+ * 単価オファー検索
20
10
  */
21
- search(params: Omit<factory.unitPriceOffer.ISearchConditions, 'project'> & IProjectionSearchConditions): Promise<IUnitPriceOfferAsSearchResult[]>;
11
+ findUnitPriceOffers(params: IFindParams): Promise<IUnitPriceOfferAsFindResult[]>;
22
12
  /**
23
13
  * プロダクト指定で、コードによる冪等編集
24
14
  */
@@ -8,9 +8,9 @@ const service_1 = require("../service");
8
8
  */
9
9
  class OfferService extends service_1.Service {
10
10
  /**
11
- * オファー検索
11
+ * 単価オファー検索
12
12
  */
13
- async search(params) {
13
+ async findUnitPriceOffers(params) {
14
14
  return this.fetch({
15
15
  uri: '/offers',
16
16
  method: 'GET',
@@ -1,34 +1,14 @@
1
1
  import { factory } from '../../factory';
2
2
  import { Service } from '../../service';
3
- interface ISearchConditions {
4
- limit?: number;
5
- page?: number;
6
- id?: {
7
- /**
8
- * IDリストを最大10件まで指定可能
9
- */
10
- $in?: string[];
11
- };
12
- identifier?: {
13
- /**
14
- * コードリストを最大10件まで指定可能
15
- */
16
- $in?: string[];
17
- };
18
- }
19
- type IUnitPriceSpecificationAsSearchResult = Pick<factory.unitPriceOffer.IUnitPriceOfferPriceSpecification, 'accounting' | 'price' | 'referenceQuantity'>;
20
- type IUnitPriceOfferAsSearchResult = Pick<factory.unitPriceOffer.IUnitPriceOffer, 'id' | 'identifier' | 'alternateName' | 'name'> & {
21
- priceSpecification: IUnitPriceSpecificationAsSearchResult;
22
- };
3
+ import { IFindParams, IUnitPriceOfferAsFindResult } from '../../chevreAdmin/offer/factory';
23
4
  /**
24
- * オファーサービス
5
+ * 単価オファーサービス
25
6
  */
26
7
  export declare class OfferService extends Service {
27
8
  /**
28
- * オファー検索
29
- * 管理者権限が必要です
9
+ * 管理者ロールによる単価オファー検索
30
10
  */
31
- search(params: ISearchConditions): Promise<IUnitPriceOfferAsSearchResult[]>;
11
+ search(params: IFindParams): Promise<IUnitPriceOfferAsFindResult[]>;
32
12
  /**
33
13
  * プロダクト指定で、コードによる冪等編集
34
14
  */
@@ -40,4 +20,3 @@ export declare class OfferService extends Service {
40
20
  productType: factory.product.ProductType.EventService | factory.product.ProductType.Product;
41
21
  }): Promise<void>;
42
22
  }
43
- export {};
@@ -4,44 +4,20 @@ exports.OfferService = void 0;
4
4
  const factory_1 = require("../../factory");
5
5
  const index_1 = require("../../index");
6
6
  const service_1 = require("../../service");
7
- function minimizeOffer(params) {
8
- const priceSpecification = {
9
- price: params.priceSpecification.price,
10
- referenceQuantity: params.priceSpecification.referenceQuantity,
11
- ...(typeof params.priceSpecification.accounting?.typeOf === 'string')
12
- ? { accounting: params.priceSpecification.accounting }
13
- : undefined
14
- };
15
- return {
16
- id: String(params.id),
17
- identifier: params.identifier,
18
- name: params.name,
19
- priceSpecification,
20
- ...(params.alternateName !== undefined && params.alternateName !== null) ? { alternateName: params.alternateName } : undefined
21
- };
22
- }
23
7
  /**
24
- * オファーサービス
8
+ * 単価オファーサービス
25
9
  */
26
10
  class OfferService extends service_1.Service {
27
11
  /**
28
- * オファー検索
29
- * 管理者権限が必要です
12
+ * 管理者ロールによる単価オファー検索
30
13
  */
31
14
  async search(params) {
32
- // return this.fetch({
33
- // uri: '/offers',
34
- // method: 'GET',
35
- // qs: params,
36
- // expectedStatusCodes: [status.OK]
37
- // })
38
- // .then(async (response) => response.json());
39
15
  const { auth, endpoint, project, seller } = this.options;
40
16
  const chevreAdmin = await (0, index_1.loadChevreAdmin)({ auth, endpoint });
41
- if (params.limit !== undefined && typeof params.limit !== 'number') {
17
+ if (typeof params.limit !== 'number') {
42
18
  throw new factory_1.factory.errors.Argument('limit', 'must be number');
43
19
  }
44
- if (params.page !== undefined && typeof params.page !== 'number') {
20
+ if (typeof params.page !== 'number') {
45
21
  throw new factory_1.factory.errors.Argument('page', 'must be number');
46
22
  }
47
23
  const idIn = params.id?.$in;
@@ -60,28 +36,16 @@ class OfferService extends service_1.Service {
60
36
  project,
61
37
  seller: { id: (typeof seller?.id === 'string') ? seller.id : '' }
62
38
  });
63
- const searchConditions = {
64
- // 限定された条件のみ適用
39
+ return offerService.findUnitPriceOffers({
65
40
  id: {
66
41
  $in: (Array.isArray(idIn)) ? idIn : undefined
67
42
  },
68
43
  identifier: {
69
44
  $in: (Array.isArray(identifierIn)) ? identifierIn : undefined
70
45
  },
71
- ...(typeof params.limit === 'number') ? { limit: Math.min(params.limit, 100) } : undefined,
72
- ...(typeof params.page === 'number') ? { page: Math.max(params.page, 1) } : undefined
73
- };
74
- const searchOffersResult = await offerService.search({
75
- ...searchConditions,
76
- $projection: {
77
- id: 1,
78
- identifier: 1,
79
- alternateName: 1,
80
- name: 1,
81
- priceSpecification: 1
82
- }
46
+ limit: Math.min(params.limit, 100),
47
+ page: Math.max(params.page, 1)
83
48
  });
84
- return searchOffersResult.map(minimizeOffer);
85
49
  }
86
50
  /**
87
51
  * プロダクト指定で、コードによる冪等編集