@chevre/domain 22.14.0-alpha.10 → 22.14.0-alpha.11

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.
@@ -30,9 +30,7 @@ export declare class CreativeWorkRepo {
30
30
  $unset?: {
31
31
  [key in keyof factory.creativeWork.movie.ICreativeWork]?: 1;
32
32
  };
33
- }[], options?: {
34
- replace?: boolean;
35
- }): Promise<{
33
+ }[]): Promise<{
36
34
  bulkWriteResult: BulkWriteResult;
37
35
  } | void>;
38
36
  /**
@@ -159,7 +159,11 @@ class CreativeWorkRepo {
159
159
  * コードをキーにして冪等作成
160
160
  */
161
161
  // tslint:disable-next-line:max-func-body-length
162
- upsertMoviesByIdentifier(params, options) {
162
+ upsertMoviesByIdentifier(params
163
+ // options?: {
164
+ // replace?: boolean;
165
+ // }
166
+ ) {
163
167
  return __awaiter(this, void 0, void 0, function* () {
164
168
  const bulkWriteOps = [];
165
169
  if (Array.isArray(params)) {
@@ -167,56 +171,70 @@ class CreativeWorkRepo {
167
171
  params.forEach(({ $set, $unset }) => {
168
172
  // リソースのユニークネスを保証するfilter
169
173
  const filter = {
170
- typeOf: $set.typeOf,
174
+ typeOf: { $eq: $set.typeOf },
171
175
  'project.id': { $eq: $set.project.id },
172
176
  identifier: { $eq: $set.identifier }
173
177
  };
174
- if ((options === null || options === void 0 ? void 0 : options.replace) === true) {
175
- // updateOneで再実装
176
- // const replacement: WithoutId<factory.creativeWork.movie.ICreativeWork> = replaceFields;
177
- // const replaceOne: ReplaceOneModel<factory.creativeWork.movie.ICreativeWork> = {
178
- // filter,
179
- // replacement,
180
- // upsert: true
181
- // };
182
- // bulkWriteOps.push({ replaceOne });
183
- const { id, identifier, project, typeOf } = $set, setFields = __rest($set, ["id", "identifier", "project", "typeOf"]);
184
- if (typeof identifier !== 'string' || identifier.length === 0) {
185
- throw new factory.errors.ArgumentNull('identifier');
186
- }
187
- const setOnInsert = {
188
- typeOf,
189
- project,
190
- identifier
191
- };
192
- const updateFilter = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
193
- const updateOne = {
194
- filter,
195
- update: updateFilter,
196
- upsert: true
197
- };
198
- bulkWriteOps.push({ updateOne });
199
- }
200
- else {
201
- const { typeOf, project, identifier, duration, name, additionalProperty, contentRating, headline, distributor, thumbnailUrl, datePublished } = $set, setOnInsertFields = __rest($set, ["typeOf", "project", "identifier", "duration", "name", "additionalProperty", "contentRating", "headline", "distributor", "thumbnailUrl", "datePublished"]);
202
- if (typeof identifier !== 'string' || identifier.length === 0) {
203
- throw new factory.errors.ArgumentNull('identifier');
204
- }
205
- const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { typeOf,
206
- project,
207
- identifier });
208
- const updateFilter = {
209
- $setOnInsert: setOnInsert,
210
- // 変更可能な属性のみ上書き
211
- $set: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (name !== undefined) ? { name } : undefined), (contentRating !== undefined) ? { contentRating } : undefined), (duration !== undefined) ? { duration } : undefined), (headline !== undefined) ? { headline } : undefined), (datePublished !== undefined) ? { datePublished } : undefined), (distributor !== undefined) ? { distributor } : undefined), (typeof thumbnailUrl === 'string') ? { thumbnailUrl } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty } : [])
212
- };
213
- const updateOne = {
214
- filter,
215
- update: updateFilter,
216
- upsert: true
217
- };
218
- bulkWriteOps.push({ updateOne });
178
+ const { id, identifier, project, typeOf } = $set, setFields = __rest($set, ["id", "identifier", "project", "typeOf"]);
179
+ if (typeof identifier !== 'string' || identifier.length === 0) {
180
+ throw new factory.errors.ArgumentNull('identifier');
219
181
  }
182
+ const setOnInsert = {
183
+ typeOf,
184
+ project,
185
+ identifier
186
+ };
187
+ const updateFilter = Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
188
+ const updateOne = {
189
+ filter,
190
+ update: updateFilter,
191
+ upsert: true
192
+ };
193
+ bulkWriteOps.push({ updateOne });
194
+ // if (options?.replace === true) {
195
+ // } else {
196
+ // const {
197
+ // typeOf, project, identifier,
198
+ // duration,
199
+ // name,
200
+ // additionalProperty,
201
+ // contentRating,
202
+ // headline,
203
+ // distributor,
204
+ // thumbnailUrl,
205
+ // datePublished,
206
+ // ...setOnInsertFields
207
+ // } = $set;
208
+ // if (typeof identifier !== 'string' || identifier.length === 0) {
209
+ // throw new factory.errors.ArgumentNull('identifier');
210
+ // }
211
+ // const setOnInsert: MatchKeysAndValues<factory.creativeWork.movie.ICreativeWork> = {
212
+ // ...setOnInsertFields,
213
+ // typeOf,
214
+ // project,
215
+ // identifier
216
+ // };
217
+ // const updateFilter: UpdateFilter<factory.creativeWork.movie.ICreativeWork> = {
218
+ // $setOnInsert: setOnInsert,
219
+ // // 変更可能な属性のみ上書き
220
+ // $set: {
221
+ // ...(name !== undefined) ? { name } : undefined,
222
+ // ...(contentRating !== undefined) ? { contentRating } : undefined,
223
+ // ...(duration !== undefined) ? { duration } : undefined,
224
+ // ...(headline !== undefined) ? { headline } : undefined,
225
+ // ...(datePublished !== undefined) ? { datePublished } : undefined,
226
+ // ...(distributor !== undefined) ? { distributor } : undefined,
227
+ // ...(typeof thumbnailUrl === 'string') ? { thumbnailUrl } : undefined,
228
+ // ...(Array.isArray(additionalProperty)) ? { additionalProperty } : []
229
+ // }
230
+ // };
231
+ // const updateOne: UpdateOneModel<factory.creativeWork.movie.ICreativeWork> = {
232
+ // filter,
233
+ // update: updateFilter,
234
+ // upsert: true
235
+ // };
236
+ // bulkWriteOps.push({ updateOne });
237
+ // }
220
238
  });
221
239
  }
222
240
  if (bulkWriteOps.length > 0) {
@@ -36,7 +36,8 @@ function updateEvent4ttts(params) {
36
36
  targetCollection: {
37
37
  // id: params.attributes.identifier,
38
38
  typeOf: factory.eventType.ScreeningEvent
39
- }
39
+ },
40
+ instrument: { typeOf: 'Task' }
40
41
  };
41
42
  const action = yield repos.action.start(actionAttributes);
42
43
  let savedEvent;
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "dependencies": {
12
12
  "@aws-sdk/client-cognito-identity-provider": "3.600.0",
13
13
  "@aws-sdk/credential-providers": "3.600.0",
14
- "@chevre/factory": "4.399.0-alpha.11",
14
+ "@chevre/factory": "4.399.0-alpha.12",
15
15
  "@cinerino/sdk": "12.2.0",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.4.0-alpha.1",
@@ -115,5 +115,5 @@
115
115
  "postversion": "git push origin --tags",
116
116
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
117
117
  },
118
- "version": "22.14.0-alpha.10"
118
+ "version": "22.14.0-alpha.11"
119
119
  }
@@ -1,58 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../lib/index';
6
-
7
- const PROJECT_ID = String(process.env.PROJECT_ID);
8
-
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
-
12
- const creativeWorkRepo = await chevre.repository.CreativeWork.createInstance(mongoose.connection);
13
-
14
- const result = await creativeWorkRepo.upsertMoviesByIdentifier(
15
- [
16
- {
17
- $set: {
18
- id: '',
19
- identifier: '20231215',
20
- typeOf: chevre.factory.creativeWorkType.Movie,
21
- duration: 'PT2H',
22
- name: { ja: '名探偵コナン ゼロの執行人', en: 'Detective Conan Zero Enforcer' },
23
- offers: {
24
- typeOf: chevre.factory.offerType.Offer,
25
- availabilityEnds: moment('2118-11-04T15:00:00.000Z')
26
- .toDate(),
27
- availabilityStarts: moment('2018-11-25T15:00:00.000Z')
28
- .toDate()
29
- },
30
- project: { typeOf: chevre.factory.organizationType.Project, id: PROJECT_ID },
31
- additionalProperty: [
32
- {
33
- name: 'posterImage',
34
- value: 'https://iwiz-movies.c.yimg.jp/c/movies/pict/p/p/90/cb/174755_02.jpg'
35
- }
36
- ],
37
- // headline: 'サブタイトルサブタイトル',
38
- datePublished: moment('2018-11-04T15:00:00.000Z')
39
- .toDate(),
40
- distributor: {
41
- id: '5e35398a8067a30012dd6717',
42
- codeValue: '001',
43
- ...{
44
- distributorType: '001'
45
- }
46
- }
47
- },
48
- $unset: { headline: 1 }
49
- }
50
- ],
51
- { replace: true }
52
- );
53
- console.log('result:', result);
54
- }
55
-
56
- main()
57
- .then(console.log)
58
- .catch(console.error);