@cinerino/sdk 12.3.0-alpha.0 → 12.3.0-alpha.2

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,75 @@
1
+ // tslint:disable:no-console
2
+ // tslint:disable-next-line:no-implicit-dependencies
3
+ import * as moment from 'moment';
4
+ import { factory, loadChevreConsole } from '../../../../lib/index';
5
+ import * as auth from '../../auth/authAsAdmin';
6
+
7
+ const project = { id: String(process.env.PROJECT_ID) };
8
+
9
+ async function main() {
10
+ const authClient = await auth.login();
11
+ await authClient.refreshAccessToken();
12
+ const loginTicket = authClient.verifyIdToken({});
13
+ console.log('username is', loginTicket.getUsername());
14
+
15
+ const eventService = await (await loadChevreConsole({
16
+ endpoint: <string>process.env.CHEVRE_ENDPOINT,
17
+ auth: authClient
18
+ })).createEventInstance({
19
+ project,
20
+ seller: { id: '' }
21
+ });
22
+
23
+ await eventService.createScreeningEvents(
24
+ [
25
+ {
26
+ typeOf: factory.eventType.ScreeningEvent,
27
+ eventStatus: factory.eventStatusType.EventScheduled,
28
+ startDate: moment('2025-09-01T10:00:00Z')
29
+ .toDate(),
30
+ endDate: moment('2025-09-01T11:00:00Z')
31
+ .toDate(),
32
+ offers: {
33
+ itemOffered: { id: '681aa7c1b53b6dbbe5efbec7' },
34
+ eligibleQuantity: { maxValue: 6 },
35
+ seller: {
36
+ makesOffer: [
37
+ // {
38
+ // typeOf: factory.offerType.Offer,
39
+ // availabilityEnds: moment('2025-09-30T10:00:00Z')
40
+ // .toDate(),
41
+ // availabilityStarts: moment('2025-05-30T10:00:00Z')
42
+ // .toDate(),
43
+ // validFrom: moment('2025-05-30T10:00:00Z')
44
+ // .toDate(),
45
+ // validThrough: moment('2025-09-30T10:00:00Z')
46
+ // .toDate(),
47
+ // availableAtOrFrom: { id: '51qbjcfr72h62m06vtv5kkhgje' }
48
+ // }
49
+ ]
50
+ }
51
+ },
52
+ additionalProperty: [
53
+ { name: 'sampleCreateId', value: 'xxx' }
54
+ ]
55
+ // project: { id: project.id, typeOf: factory.organizationType.Project },
56
+ // location: {
57
+ // branchCode: '10'
58
+ // },
59
+ // superEvent: { id: '7k9ayl8hc' }
60
+ }
61
+ ],
62
+ {
63
+ superEventId: '7k9ayl8hc',
64
+ locationBranchCode: '10',
65
+ hasTicketedSeat: true
66
+ }
67
+ );
68
+ console.log('created.');
69
+ }
70
+
71
+ main()
72
+ .then(() => {
73
+ console.log('success!');
74
+ })
75
+ .catch(console.error);
@@ -1,12 +1,12 @@
1
1
  // tslint:disable:no-console
2
2
  // tslint:disable-next-line:no-implicit-dependencies
3
- import * as moment from 'moment';
3
+ import * as moment from 'moment-timezone';
4
4
  import * as client from '../../../../lib/index';
5
5
  import * as auth from '../../auth/authAsAdmin';
6
6
 
7
7
  const PROJECT_ID = String(process.env.PROJECT_ID);
8
8
  const SELLER_ID = '59d20831e53ebc2b4e774466';
9
- const EVENT_SERVICE_ID = '656038908b1cd5ce629f5992';
9
+ const EVENT_SERVICE_ID = '681aa7c1b53b6dbbe5efbec7';
10
10
  const AVAILABLE_AT_OR_FROM_ID = '51qbjcfr72h62m06vtv5kkhgje';
11
11
  const ADDITIONAL_PROPERTY_NAME = 'sampleCreateId';
12
12
 
@@ -24,34 +24,38 @@ async function main() {
24
24
  seller: { id: SELLER_ID }
25
25
  });
26
26
 
27
+ const today = moment()
28
+ .tz('Asia/Tokyo')
29
+ .format('YYYY-MM-DD');
27
30
  await eventService.upsertManyByAdditionalProperty({
28
31
  filter: { name: ADDITIONAL_PROPERTY_NAME },
29
32
  attributes: [
30
33
  {
31
34
  typeOf: client.factory.eventType.ScreeningEvent,
32
- project: {
33
- typeOf: client.factory.organizationType.Project,
34
- id: PROJECT_ID
35
- },
36
- doorTime: moment('2025-08-27T07:00:00.000Z')
35
+ // project: {
36
+ // typeOf: client.factory.organizationType.Project,
37
+ // id: PROJECT_ID
38
+ // },
39
+ doorTime: moment(`${today}T13:00:00Z`)
37
40
  .toDate(),
38
- startDate: moment('2025-08-27T07:00:00.000Z')
41
+ startDate: moment(`${today}T13:00:00Z`)
39
42
  .toDate(),
40
- endDate: moment('2025-08-27T07:10:00.000Z')
43
+ endDate: moment(`${today}T14:00:00Z`)
41
44
  .toDate(),
42
45
  eventStatus: client.factory.eventStatusType.EventScheduled,
43
46
  additionalProperty: [
44
47
  // { name: ADDITIONAL_PROPERTY_NAME, value: `fromSamples:${Date.now()}` }
45
48
  {
46
49
  name: ADDITIONAL_PROPERTY_NAME, value: `fromSamples:${moment()
47
- .format('YYYYMMDD')}`
50
+ .format('YYYY-MM-DD HH:mm')}`
48
51
  }
49
52
  ],
53
+ // maximumPhysicalAttendeeCapacity: 3,
50
54
  location: {
51
- branchCode: '90'
55
+ branchCode: '10'
52
56
  },
53
57
  superEvent: {
54
- id: 'bkeuv7fdu'
58
+ id: '7k9ayl8hc'
55
59
  },
56
60
  offers: {
57
61
  unacceptedPaymentMethod: [],
@@ -66,13 +70,13 @@ async function main() {
66
70
  {
67
71
  typeOf: client.factory.offerType.Offer,
68
72
  availableAtOrFrom: { id: AVAILABLE_AT_OR_FROM_ID }, // <-販売アプリケーションIDを指定する
69
- availabilityStarts: moment('2025-08-27T00:00:00.000Z')
73
+ availabilityStarts: moment(`${today}T13:00:00Z`)
70
74
  .toDate(),
71
- availabilityEnds: moment('2025-08-27T00:00:00.000Z')
75
+ availabilityEnds: moment(`${today}T14:00:00Z`)
72
76
  .toDate(),
73
- validFrom: moment('2025-08-27T00:00:00.000Z')
77
+ validFrom: moment(`${today}T13:00:00Z`)
74
78
  .toDate(),
75
- validThrough: moment('2025-08-27T15:00:00.000Z')
79
+ validThrough: moment(`${today}T14:00:00Z`)
76
80
  .toDate()
77
81
  }
78
82
  ]
@@ -20,6 +20,8 @@ export declare class EventService extends Service {
20
20
  name: string;
21
21
  };
22
22
  update: boolean;
23
+ superEventId: string;
24
+ locationBranchCode: string;
23
25
  }): Promise<void>;
24
26
  /**
25
27
  * イベント部分更新
@@ -69,22 +69,21 @@ var EventService = /** @class */ (function (_super) {
69
69
  * 存在すれば、一部属性を更新する(eventStatus,superEvent,offers.seller.makesOffer)
70
70
  */
71
71
  EventService.prototype.upsertManyByAdditionalProperty = function (params, options) {
72
- var _a, _b, _c, _d;
73
72
  return __awaiter(this, void 0, void 0, function () {
74
73
  var superEventId, locationBranchCode;
75
- return __generator(this, function (_e) {
76
- switch (_e.label) {
74
+ return __generator(this, function (_a) {
75
+ switch (_a.label) {
77
76
  case 0:
78
77
  if (!Array.isArray(params) || params.length === 0) {
79
78
  throw new factory.errors.ArgumentNull('body');
80
79
  }
81
- superEventId = (_b = (_a = params[0]) === null || _a === void 0 ? void 0 : _a.superEvent) === null || _b === void 0 ? void 0 : _b.id;
82
- locationBranchCode = (_d = (_c = params[0]) === null || _c === void 0 ? void 0 : _c.location) === null || _d === void 0 ? void 0 : _d.branchCode;
80
+ superEventId = options.superEventId;
81
+ locationBranchCode = options.locationBranchCode;
83
82
  if (typeof superEventId !== 'string' || superEventId === '') {
84
- throw new factory.errors.ArgumentNull('superEvent.id');
83
+ throw new factory.errors.ArgumentNull('superEventId');
85
84
  }
86
85
  if (typeof locationBranchCode !== 'string' || locationBranchCode === '') {
87
- throw new factory.errors.ArgumentNull('location.branchCode');
86
+ throw new factory.errors.ArgumentNull('locationBranchCode');
88
87
  }
89
88
  return [4 /*yield*/, this.fetch({
90
89
  uri: '/events',
@@ -100,7 +99,7 @@ var EventService = /** @class */ (function (_super) {
100
99
  expectedStatusCodes: [http_status_1.NO_CONTENT]
101
100
  })];
102
101
  case 1:
103
- _e.sent();
102
+ _a.sent();
104
103
  return [2 /*return*/];
105
104
  }
106
105
  });
@@ -3,6 +3,20 @@ import { Service } from '../../service';
3
3
  declare type ISendEmailMessageOnEventUpdated = Pick<factory.action.transfer.send.message.email.IAttributes, 'purpose' | 'recipient'> & {
4
4
  object: factory.action.transfer.send.message.email.IObjectAsEmailMessage;
5
5
  };
6
+ declare type ICreateScreeningEventParams = Omit<factory.event.ICreateParams<factory.eventType.ScreeningEvent>, 'location' | 'superEvent'> & {
7
+ /**
8
+ * ルームコードを指定
9
+ */
10
+ location: {
11
+ branchCode: string;
12
+ };
13
+ /**
14
+ * 施設コンテンツIDを指定
15
+ */
16
+ superEvent: {
17
+ id: string;
18
+ };
19
+ };
6
20
  /**
7
21
  * イベントサービス
8
22
  */
@@ -16,7 +30,7 @@ export declare class EventService extends Service {
16
30
  /**
17
31
  * 最大長:10
18
32
  */
19
- attributes: factory.event.ICreateParams<factory.eventType.ScreeningEvent>[];
33
+ attributes: ICreateScreeningEventParams[];
20
34
  filter: {
21
35
  /**
22
36
  * キーにする追加特性name
@@ -50,6 +50,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
50
50
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
51
  }
52
52
  };
53
+ var __rest = (this && this.__rest) || function (s, e) {
54
+ var t = {};
55
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
56
+ t[p] = s[p];
57
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
58
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
59
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
60
+ t[p[i]] = s[p[i]];
61
+ }
62
+ return t;
63
+ };
53
64
  Object.defineProperty(exports, "__esModule", { value: true });
54
65
  exports.EventService = void 0;
55
66
  var factory = require("../../factory");
@@ -69,40 +80,60 @@ var EventService = /** @class */ (function (_super) {
69
80
  * 存在すれば、一部属性を更新する(eventStatus,superEvent,offers.seller.makesOffer)
70
81
  */
71
82
  EventService.prototype.upsertManyByAdditionalProperty = function (params) {
83
+ var _a, _b, _c, _d;
72
84
  return __awaiter(this, void 0, void 0, function () {
73
- var _a, auth, endpoint, project, seller, chevreAdmin, eventService;
74
- return __generator(this, function (_b) {
75
- switch (_b.label) {
85
+ var superEventId, locationBranchCode, upsertParams, _e, auth, endpoint, project, seller, chevreAdmin, eventService;
86
+ return __generator(this, function (_f) {
87
+ switch (_f.label) {
76
88
  case 0:
77
- _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller;
89
+ if (!Array.isArray(params.attributes) || params.attributes.length === 0) {
90
+ throw new factory.errors.ArgumentNull('body');
91
+ }
92
+ superEventId = (_b = (_a = params.attributes[0]) === null || _a === void 0 ? void 0 : _a.superEvent) === null || _b === void 0 ? void 0 : _b.id;
93
+ locationBranchCode = (_d = (_c = params.attributes[0]) === null || _c === void 0 ? void 0 : _c.location) === null || _d === void 0 ? void 0 : _d.branchCode;
94
+ if (typeof superEventId !== 'string' || superEventId === '') {
95
+ throw new factory.errors.ArgumentNull('superEvent.id');
96
+ }
97
+ if (typeof locationBranchCode !== 'string' || locationBranchCode === '') {
98
+ throw new factory.errors.ArgumentNull('location.branchCode');
99
+ }
100
+ upsertParams = params.attributes.map(function (_a) {
101
+ var location = _a.location, superEvent = _a.superEvent, identifier = _a.identifier, createFields = __rest(_a, ["location", "superEvent", "identifier"]);
102
+ return createFields;
103
+ });
104
+ _e = this.options, auth = _e.auth, endpoint = _e.endpoint, project = _e.project, seller = _e.seller;
78
105
  return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint })];
79
106
  case 1:
80
- chevreAdmin = _b.sent();
107
+ chevreAdmin = _f.sent();
81
108
  return [4 /*yield*/, chevreAdmin.createEventInstance({
82
109
  project: project,
83
110
  seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' }
84
111
  })];
85
112
  case 2:
86
- eventService = _b.sent();
87
- return [4 /*yield*/, eventService.upsertManyByAdditionalProperty(params.attributes, {
113
+ eventService = _f.sent();
114
+ return [4 /*yield*/, eventService.upsertManyByAdditionalProperty(upsertParams, {
88
115
  filter: { name: params.filter.name },
89
- update: false
116
+ update: false,
117
+ superEventId: superEventId,
118
+ locationBranchCode: locationBranchCode
90
119
  })];
91
120
  case 3:
92
- _b.sent();
121
+ _f.sent();
93
122
  return [4 /*yield*/, new Promise(function (resolve) {
94
123
  setTimeout(function () { resolve(); },
95
124
  // tslint:disable-next-line:no-magic-numbers
96
125
  1000);
97
126
  })];
98
127
  case 4:
99
- _b.sent();
100
- return [4 /*yield*/, eventService.upsertManyByAdditionalProperty(params.attributes, {
128
+ _f.sent();
129
+ return [4 /*yield*/, eventService.upsertManyByAdditionalProperty(upsertParams, {
101
130
  filter: { name: params.filter.name },
102
- update: true
131
+ update: true,
132
+ superEventId: superEventId,
133
+ locationBranchCode: locationBranchCode
103
134
  })];
104
135
  case 5:
105
- _b.sent();
136
+ _f.sent();
106
137
  return [2 /*return*/];
107
138
  }
108
139
  });
package/lib/bundle.js CHANGED
@@ -2575,22 +2575,21 @@ var EventService = /** @class */ (function (_super) {
2575
2575
  * 存在すれば、一部属性を更新する(eventStatus,superEvent,offers.seller.makesOffer)
2576
2576
  */
2577
2577
  EventService.prototype.upsertManyByAdditionalProperty = function (params, options) {
2578
- var _a, _b, _c, _d;
2579
2578
  return __awaiter(this, void 0, void 0, function () {
2580
2579
  var superEventId, locationBranchCode;
2581
- return __generator(this, function (_e) {
2582
- switch (_e.label) {
2580
+ return __generator(this, function (_a) {
2581
+ switch (_a.label) {
2583
2582
  case 0:
2584
2583
  if (!Array.isArray(params) || params.length === 0) {
2585
2584
  throw new factory.errors.ArgumentNull('body');
2586
2585
  }
2587
- superEventId = (_b = (_a = params[0]) === null || _a === void 0 ? void 0 : _a.superEvent) === null || _b === void 0 ? void 0 : _b.id;
2588
- locationBranchCode = (_d = (_c = params[0]) === null || _c === void 0 ? void 0 : _c.location) === null || _d === void 0 ? void 0 : _d.branchCode;
2586
+ superEventId = options.superEventId;
2587
+ locationBranchCode = options.locationBranchCode;
2589
2588
  if (typeof superEventId !== 'string' || superEventId === '') {
2590
- throw new factory.errors.ArgumentNull('superEvent.id');
2589
+ throw new factory.errors.ArgumentNull('superEventId');
2591
2590
  }
2592
2591
  if (typeof locationBranchCode !== 'string' || locationBranchCode === '') {
2593
- throw new factory.errors.ArgumentNull('location.branchCode');
2592
+ throw new factory.errors.ArgumentNull('locationBranchCode');
2594
2593
  }
2595
2594
  return [4 /*yield*/, this.fetch({
2596
2595
  uri: '/events',
@@ -2606,7 +2605,7 @@ var EventService = /** @class */ (function (_super) {
2606
2605
  expectedStatusCodes: [http_status_1.NO_CONTENT]
2607
2606
  })];
2608
2607
  case 1:
2609
- _e.sent();
2608
+ _a.sent();
2610
2609
  return [2 /*return*/];
2611
2610
  }
2612
2611
  });
@@ -20730,6 +20729,17 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
20730
20729
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
20731
20730
  }
20732
20731
  };
20732
+ var __rest = (this && this.__rest) || function (s, e) {
20733
+ var t = {};
20734
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
20735
+ t[p] = s[p];
20736
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
20737
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
20738
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20739
+ t[p[i]] = s[p[i]];
20740
+ }
20741
+ return t;
20742
+ };
20733
20743
  Object.defineProperty(exports, "__esModule", { value: true });
20734
20744
  exports.EventService = void 0;
20735
20745
  var factory = require("../../factory");
@@ -20749,40 +20759,60 @@ var EventService = /** @class */ (function (_super) {
20749
20759
  * 存在すれば、一部属性を更新する(eventStatus,superEvent,offers.seller.makesOffer)
20750
20760
  */
20751
20761
  EventService.prototype.upsertManyByAdditionalProperty = function (params) {
20762
+ var _a, _b, _c, _d;
20752
20763
  return __awaiter(this, void 0, void 0, function () {
20753
- var _a, auth, endpoint, project, seller, chevreAdmin, eventService;
20754
- return __generator(this, function (_b) {
20755
- switch (_b.label) {
20764
+ var superEventId, locationBranchCode, upsertParams, _e, auth, endpoint, project, seller, chevreAdmin, eventService;
20765
+ return __generator(this, function (_f) {
20766
+ switch (_f.label) {
20756
20767
  case 0:
20757
- _a = this.options, auth = _a.auth, endpoint = _a.endpoint, project = _a.project, seller = _a.seller;
20768
+ if (!Array.isArray(params.attributes) || params.attributes.length === 0) {
20769
+ throw new factory.errors.ArgumentNull('body');
20770
+ }
20771
+ superEventId = (_b = (_a = params.attributes[0]) === null || _a === void 0 ? void 0 : _a.superEvent) === null || _b === void 0 ? void 0 : _b.id;
20772
+ locationBranchCode = (_d = (_c = params.attributes[0]) === null || _c === void 0 ? void 0 : _c.location) === null || _d === void 0 ? void 0 : _d.branchCode;
20773
+ if (typeof superEventId !== 'string' || superEventId === '') {
20774
+ throw new factory.errors.ArgumentNull('superEvent.id');
20775
+ }
20776
+ if (typeof locationBranchCode !== 'string' || locationBranchCode === '') {
20777
+ throw new factory.errors.ArgumentNull('location.branchCode');
20778
+ }
20779
+ upsertParams = params.attributes.map(function (_a) {
20780
+ var location = _a.location, superEvent = _a.superEvent, identifier = _a.identifier, createFields = __rest(_a, ["location", "superEvent", "identifier"]);
20781
+ return createFields;
20782
+ });
20783
+ _e = this.options, auth = _e.auth, endpoint = _e.endpoint, project = _e.project, seller = _e.seller;
20758
20784
  return [4 /*yield*/, index_1.loadChevreAdmin({ auth: auth, endpoint: endpoint })];
20759
20785
  case 1:
20760
- chevreAdmin = _b.sent();
20786
+ chevreAdmin = _f.sent();
20761
20787
  return [4 /*yield*/, chevreAdmin.createEventInstance({
20762
20788
  project: project,
20763
20789
  seller: { id: (typeof (seller === null || seller === void 0 ? void 0 : seller.id) === 'string') ? seller.id : '' }
20764
20790
  })];
20765
20791
  case 2:
20766
- eventService = _b.sent();
20767
- return [4 /*yield*/, eventService.upsertManyByAdditionalProperty(params.attributes, {
20792
+ eventService = _f.sent();
20793
+ return [4 /*yield*/, eventService.upsertManyByAdditionalProperty(upsertParams, {
20768
20794
  filter: { name: params.filter.name },
20769
- update: false
20795
+ update: false,
20796
+ superEventId: superEventId,
20797
+ locationBranchCode: locationBranchCode
20770
20798
  })];
20771
20799
  case 3:
20772
- _b.sent();
20800
+ _f.sent();
20773
20801
  return [4 /*yield*/, new Promise(function (resolve) {
20774
20802
  setTimeout(function () { resolve(); },
20775
20803
  // tslint:disable-next-line:no-magic-numbers
20776
20804
  1000);
20777
20805
  })];
20778
20806
  case 4:
20779
- _b.sent();
20780
- return [4 /*yield*/, eventService.upsertManyByAdditionalProperty(params.attributes, {
20807
+ _f.sent();
20808
+ return [4 /*yield*/, eventService.upsertManyByAdditionalProperty(upsertParams, {
20781
20809
  filter: { name: params.filter.name },
20782
- update: true
20810
+ update: true,
20811
+ superEventId: superEventId,
20812
+ locationBranchCode: locationBranchCode
20783
20813
  })];
20784
20814
  case 5:
20785
- _b.sent();
20815
+ _f.sent();
20786
20816
  return [2 /*return*/];
20787
20817
  }
20788
20818
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinerino/sdk",
3
- "version": "12.3.0-alpha.0",
3
+ "version": "12.3.0-alpha.2",
4
4
  "description": "Cinerino SDK",
5
5
  "main": "./lib/index.js",
6
6
  "browser": {
@@ -78,6 +78,7 @@
78
78
  "jwt-decode": "^2.2.0",
79
79
  "mocha": "10.6.0",
80
80
  "moment": "2.30.1",
81
+ "moment-timezone": "0.6.0",
81
82
  "nock": "13.4.0",
82
83
  "nyc": "17.0.0",
83
84
  "open": "^8.2.1",
@@ -92,7 +93,7 @@
92
93
  "watchify": "^3.11.1"
93
94
  },
94
95
  "dependencies": {
95
- "@chevre/factory": "4.398.0-alpha.0",
96
+ "@chevre/factory": "4.398.0-alpha.2",
96
97
  "debug": "3.2.7",
97
98
  "http-status": "1.7.4",
98
99
  "idtoken-verifier": "2.0.3",