@cinerino/sdk 12.5.0-alpha.6 → 12.5.0-alpha.7

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,39 @@
1
+ // tslint:disable:no-implicit-dependencies no-console
2
+ // import * as moment from 'moment';
3
+
4
+ import * as client from '../../../../lib/index';
5
+
6
+ const PROJECT_ID = String(process.env.PROJECT_ID);
7
+
8
+ async function main() {
9
+ const authClient = await client.auth.ClientCredentials.createInstance({
10
+ domain: <string>process.env.CHEVRE_AUTHORIZE_SERVER_DOMAIN,
11
+ clientId: <string>process.env.CHEVRE_CLIENT_ID,
12
+ clientSecret: <string>process.env.CHEVRE_CLIENT_SECRET,
13
+ scopes: [],
14
+ state: ''
15
+ });
16
+
17
+ const noteService = await (await client.loadChevre({
18
+ endpoint: <string>process.env.CHEVRE_ENDPOINT,
19
+ auth: authClient
20
+ })).createNoteInstance({
21
+ project: { id: PROJECT_ID },
22
+ seller: { id: '' }
23
+ });
24
+
25
+ const result = await noteService.findPublicNotes({
26
+ page: 1,
27
+ limit: 10,
28
+ aboutTypeOf: client.factory.product.ProductType.EventService,
29
+ aboutIds: ['x', '656038908b1cd5ce629f5992']
30
+ });
31
+ console.log(result);
32
+ console.log(result.length, 'notes returned');
33
+ }
34
+
35
+ main()
36
+ .then(() => {
37
+ console.log('success!');
38
+ })
39
+ .catch(console.error);
@@ -24,8 +24,9 @@ async function main() {
24
24
  const today = moment()
25
25
  .tz('Asia/Tokyo')
26
26
  .format('YYYY-MM-DD');
27
- const identifier = '2025093001';
27
+ const identifier = '2025101001';
28
28
  const itemOfferedIdentifier = '2025093001itemOfferedIdentifier';
29
+ const tierIdentifier = 'silver';
29
30
  await productOfferService.createValidForMemberTierByIdentifier(
30
31
  [
31
32
  {
@@ -34,7 +35,7 @@ async function main() {
34
35
  .toDate(),
35
36
  validThrough: moment(`${today}T14:00:00Z`)
36
37
  .toDate(),
37
- validForMemberTier: { identifier: 'bronze' }
38
+ validForMemberTier: { identifier: tierIdentifier }
38
39
  }
39
40
  ],
40
41
  {
@@ -52,7 +53,7 @@ async function main() {
52
53
  .toDate(),
53
54
  validThrough: moment(`${today}T14:00:00Z`)
54
55
  .toDate(),
55
- validForMemberTier: { identifier: 'bronze' }
56
+ validForMemberTier: { identifier: tierIdentifier }
56
57
  }
57
58
  ],
58
59
  {
@@ -0,0 +1,32 @@
1
+ import * as factory from '../factory';
2
+ import { Service } from '../service';
3
+ declare type INoteDigitalDocument = factory.creativeWork.noteDigitalDocument.INoteDigitalDocument;
4
+ export interface IFindParams {
5
+ limit: number;
6
+ page: number;
7
+ /**
8
+ * 主題リソースタイプ
9
+ */
10
+ aboutTypeOf: factory.product.ProductType.EventService;
11
+ /**
12
+ * 主題リソースIDリスト
13
+ * max: 10
14
+ */
15
+ aboutIds?: string[];
16
+ /**
17
+ * メモ識別子リスト
18
+ * max: 10
19
+ */
20
+ identifiers?: string[];
21
+ }
22
+ export declare type INoteAsFindResult = Pick<INoteDigitalDocument, 'about' | 'id' | 'identifier' | 'text'>;
23
+ /**
24
+ * メモサービス
25
+ */
26
+ export declare class NoteService extends Service {
27
+ /**
28
+ * 公開メモを検索する
29
+ */
30
+ findPublicNotes(params: IFindParams): Promise<INoteAsFindResult[]>;
31
+ }
32
+ export {};
@@ -0,0 +1,87 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.NoteService = void 0;
55
+ var http_status_1 = require("http-status");
56
+ var service_1 = require("../service");
57
+ var BASE_URI = '/creativeWorks/noteDigitalDocument';
58
+ /**
59
+ * メモサービス
60
+ */
61
+ var NoteService = /** @class */ (function (_super) {
62
+ __extends(NoteService, _super);
63
+ function NoteService() {
64
+ return _super !== null && _super.apply(this, arguments) || this;
65
+ }
66
+ /**
67
+ * 公開メモを検索する
68
+ */
69
+ NoteService.prototype.findPublicNotes = function (params) {
70
+ return __awaiter(this, void 0, void 0, function () {
71
+ var _this = this;
72
+ return __generator(this, function (_a) {
73
+ return [2 /*return*/, this.fetch({
74
+ uri: BASE_URI,
75
+ method: 'GET',
76
+ qs: params,
77
+ expectedStatusCodes: [http_status_1.OK]
78
+ })
79
+ .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
80
+ return [2 /*return*/, response.json()];
81
+ }); }); })];
82
+ });
83
+ });
84
+ };
85
+ return NoteService;
86
+ }(service_1.Service));
87
+ exports.NoteService = NoteService;
@@ -4,6 +4,7 @@ import type { CreativeWorkService } from './chevre/creativeWork';
4
4
  import type { EmailMessageService } from './chevre/emailMessage';
5
5
  import type { EventService } from './chevre/event';
6
6
  import type { EventSeriesService } from './chevre/eventSeries';
7
+ import type { NoteService } from './chevre/note';
7
8
  import type { PaymentProductService } from './chevre/paymentService';
8
9
  import type { PlaceService } from './chevre/place';
9
10
  import type { HasPOSService } from './chevre/place/hasPOS';
@@ -48,6 +49,13 @@ export declare namespace service {
48
49
  namespace EventSeries {
49
50
  let svc: typeof EventSeriesService | undefined;
50
51
  }
52
+ /**
53
+ * メモサービス
54
+ */
55
+ type Note = NoteService;
56
+ namespace Note {
57
+ let svc: typeof NoteService | undefined;
58
+ }
51
59
  /**
52
60
  * 決済商品サービス
53
61
  */
@@ -111,6 +119,7 @@ export declare class Chevre {
111
119
  createEmailMessageInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<EmailMessageService>;
112
120
  createEventInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<EventService>;
113
121
  createEventSeriesInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<EventSeriesService>;
122
+ createNoteInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<NoteService>;
114
123
  createPaymentProductInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<PaymentProductService>;
115
124
  createPlaceInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<PlaceService>;
116
125
  createHasPOSInstance(params: Pick<IOptions, 'project'> & Pick<IAdditionalOptions, 'seller'>): Promise<HasPOSService>;
@@ -65,6 +65,9 @@ var service;
65
65
  var EventSeries;
66
66
  (function (EventSeries) {
67
67
  })(EventSeries = service.EventSeries || (service.EventSeries = {}));
68
+ var Note;
69
+ (function (Note) {
70
+ })(Note = service.Note || (service.Note = {}));
68
71
  var PaymentProduct;
69
72
  (function (PaymentProduct) {
70
73
  })(PaymentProduct = service.PaymentProduct || (service.PaymentProduct = {}));
@@ -182,6 +185,23 @@ var Chevre = /** @class */ (function () {
182
185
  });
183
186
  });
184
187
  };
188
+ Chevre.prototype.createNoteInstance = function (params) {
189
+ return __awaiter(this, void 0, void 0, function () {
190
+ var _a;
191
+ return __generator(this, function (_b) {
192
+ switch (_b.label) {
193
+ case 0:
194
+ if (!(service.Note.svc === undefined)) return [3 /*break*/, 2];
195
+ _a = service.Note;
196
+ return [4 /*yield*/, Promise.resolve().then(function () { return require('./chevre/note'); })];
197
+ case 1:
198
+ _a.svc = (_b.sent()).NoteService;
199
+ _b.label = 2;
200
+ case 2: return [2 /*return*/, new service.Note.svc(__assign(__assign(__assign({}, this.options), params), { retryableStatusCodes: [] }))];
201
+ }
202
+ });
203
+ });
204
+ };
185
205
  Chevre.prototype.createPaymentProductInstance = function (params) {
186
206
  return __awaiter(this, void 0, void 0, function () {
187
207
  var _a;
@@ -17,9 +17,6 @@ interface ICreateParams {
17
17
  id: string;
18
18
  };
19
19
  }
20
- interface IDeleteParams {
21
- id: string;
22
- }
23
20
  export interface IFindParams {
24
21
  limit: number;
25
22
  page: number;
@@ -42,6 +39,10 @@ export interface IFindParams {
42
39
  * メモID
43
40
  */
44
41
  id?: string;
42
+ /**
43
+ * 読取ターゲット
44
+ */
45
+ audienceType?: factory.creativeWork.noteDigitalDocument.PermissionGranteeAudienceType.Public;
45
46
  }
46
47
  /**
47
48
  * メモサービス
@@ -56,6 +57,5 @@ export declare class NoteService extends Service {
56
57
  findNotes(params: IFindParams): Promise<(INoteDigitalDocument & {
57
58
  id: string;
58
59
  })[]>;
59
- deleteNotesByIds(params: IDeleteParams[]): Promise<void>;
60
60
  }
61
61
  export {};
@@ -121,23 +121,6 @@ var NoteService = /** @class */ (function (_super) {
121
121
  });
122
122
  });
123
123
  };
124
- NoteService.prototype.deleteNotesByIds = function (params) {
125
- return __awaiter(this, void 0, void 0, function () {
126
- return __generator(this, function (_a) {
127
- switch (_a.label) {
128
- case 0: return [4 /*yield*/, this.fetch({
129
- uri: BASE_URI,
130
- method: 'DELETE',
131
- body: params,
132
- expectedStatusCodes: [http_status_1.NO_CONTENT]
133
- })];
134
- case 1:
135
- _a.sent();
136
- return [2 /*return*/];
137
- }
138
- });
139
- });
140
- };
141
124
  return NoteService;
142
125
  }(service_1.Service));
143
126
  exports.NoteService = NoteService;
@@ -1,7 +1,12 @@
1
1
  import * as factory from '../factory';
2
2
  import { Service } from '../service';
3
- export declare type IProductWithoutCredentials = Omit<factory.product.IProduct, 'availableChannel'>;
4
- export declare type ISearchProductsResult = IProductWithoutCredentials;
3
+ export declare type IProductWithoutCredentials = Pick<factory.product.IProduct, 'additionalProperty' | 'description' | 'hasOfferCatalog' | 'id' | 'name' | 'productID' | 'project' | 'serviceOutput' | 'serviceType' | 'typeOf'>;
4
+ export declare type IProductAsFindResult = IProductWithoutCredentials & {
5
+ id: string;
6
+ };
7
+ export declare type IProductAsFindByIdResult = factory.product.IProduct & {
8
+ id: string;
9
+ };
5
10
  declare type IKeyOfProjection = keyof factory.product.IProduct | '_id';
6
11
  declare type IProjection = {
7
12
  [key in IKeyOfProjection]?: 1;
@@ -24,17 +29,16 @@ export declare class ProductService extends Service {
24
29
  }>;
25
30
  /**
26
31
  * プロダクト検索
32
+ * 公開属性のみ
27
33
  */
28
- searchProducts(params: Omit<factory.product.ISearchConditions, 'project'> & {
34
+ findProducts(params: Omit<factory.product.ISearchConditions, 'project'> & {
29
35
  $projection?: IProjection;
30
- }): Promise<{
31
- data: IProductWithoutCredentials[];
32
- }>;
36
+ }): Promise<IProductAsFindResult[]>;
33
37
  findProductById(params: {
34
38
  id: string;
35
39
  } & {
36
40
  $projection?: IProjection;
37
- }): Promise<factory.product.IProduct>;
41
+ }): Promise<IProductAsFindByIdResult>;
38
42
  updateProduct(params: factory.product.ICreateParams & {
39
43
  id: string;
40
44
  }): Promise<void>;
@@ -65,6 +65,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
65
65
  exports.ProductService = void 0;
66
66
  var http_status_1 = require("http-status");
67
67
  var service_1 = require("../service");
68
+ var BASE_URI = '/products';
68
69
  /**
69
70
  * プロダクトサービス
70
71
  */
@@ -81,7 +82,7 @@ var ProductService = /** @class */ (function (_super) {
81
82
  var _this = this;
82
83
  return __generator(this, function (_a) {
83
84
  return [2 /*return*/, this.fetch({
84
- uri: '/products',
85
+ uri: BASE_URI,
85
86
  method: 'POST',
86
87
  body: params,
87
88
  expectedStatusCodes: [http_status_1.CREATED]
@@ -100,7 +101,7 @@ var ProductService = /** @class */ (function (_super) {
100
101
  var _this = this;
101
102
  return __generator(this, function (_a) {
102
103
  return [2 /*return*/, this.fetch({
103
- uri: '/products',
104
+ uri: BASE_URI,
104
105
  method: 'POST',
105
106
  body: params,
106
107
  qs: { createIfNotExist: true },
@@ -114,29 +115,21 @@ var ProductService = /** @class */ (function (_super) {
114
115
  };
115
116
  /**
116
117
  * プロダクト検索
118
+ * 公開属性のみ
117
119
  */
118
- ProductService.prototype.searchProducts = function (params) {
120
+ ProductService.prototype.findProducts = function (params) {
119
121
  return __awaiter(this, void 0, void 0, function () {
120
122
  var _this = this;
121
123
  return __generator(this, function (_a) {
122
124
  return [2 /*return*/, this.fetch({
123
- uri: '/products',
125
+ uri: BASE_URI,
124
126
  method: 'GET',
125
127
  qs: params,
126
128
  expectedStatusCodes: [http_status_1.OK]
127
129
  })
128
- .then(function (response) { return __awaiter(_this, void 0, void 0, function () {
129
- var _a;
130
- return __generator(this, function (_b) {
131
- switch (_b.label) {
132
- case 0:
133
- _a = {};
134
- return [4 /*yield*/, response.json()];
135
- case 1: return [2 /*return*/, (_a.data = _b.sent(),
136
- _a)];
137
- }
138
- });
139
- }); })];
130
+ .then(function (response) { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
131
+ return [2 /*return*/, response.json()];
132
+ }); }); })];
140
133
  });
141
134
  });
142
135
  };
@@ -147,7 +140,7 @@ var ProductService = /** @class */ (function (_super) {
147
140
  return __generator(this, function (_a) {
148
141
  id = params.id, query = __rest(params, ["id"]);
149
142
  return [2 /*return*/, this.fetch({
150
- uri: "/products/" + encodeURIComponent(String(id)),
143
+ uri: BASE_URI + "/" + encodeURIComponent(String(id)),
151
144
  method: 'GET',
152
145
  expectedStatusCodes: [http_status_1.OK],
153
146
  qs: query
@@ -163,7 +156,7 @@ var ProductService = /** @class */ (function (_super) {
163
156
  return __generator(this, function (_a) {
164
157
  switch (_a.label) {
165
158
  case 0: return [4 /*yield*/, this.fetch({
166
- uri: "/products/" + encodeURIComponent(String(params.id)),
159
+ uri: BASE_URI + "/" + encodeURIComponent(String(params.id)),
167
160
  method: 'PUT',
168
161
  body: params,
169
162
  expectedStatusCodes: [http_status_1.NO_CONTENT]
@@ -180,7 +173,7 @@ var ProductService = /** @class */ (function (_super) {
180
173
  return __generator(this, function (_a) {
181
174
  switch (_a.label) {
182
175
  case 0: return [4 /*yield*/, this.fetch({
183
- uri: "/products/" + encodeURIComponent(String(params.id)),
176
+ uri: BASE_URI + "/" + encodeURIComponent(String(params.id)),
184
177
  method: 'DELETE',
185
178
  expectedStatusCodes: [http_status_1.NO_CONTENT]
186
179
  })];