@chevre/domain 23.0.0-alpha.0 → 23.0.0-alpha.10

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.
Files changed (35) hide show
  1. package/example/src/chevre/aggregation/createAggregateEventTasks.ts +1 -1
  2. package/example/src/chevre/checkEventDuration.ts +1 -1
  3. package/example/src/chevre/note/findNotes.ts +34 -0
  4. package/example/src/chevre/note/upsertNotesByIdentifier.ts +10 -5
  5. package/example/src/chevre/product/findHasOfferCatalog.ts +27 -0
  6. package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +48 -0
  7. package/example/src/chevre/roles/{addAdminProductOfferPermissionIfNotExists.ts → addAdminProductReadPermissionIfNotExists.ts} +20 -19
  8. package/example/src/chevre/unsetUnnecessaryFields.ts +5 -7
  9. package/lib/chevre/factory/event.d.ts +1 -1
  10. package/lib/chevre/repo/event.d.ts +14 -14
  11. package/lib/chevre/repo/event.js +0 -1
  12. package/lib/chevre/repo/mongoose/schemas/event.d.ts +1 -1
  13. package/lib/chevre/repo/mongoose/schemas/eventSeries.d.ts +2 -2
  14. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +5 -14
  15. package/lib/chevre/repo/mongoose/schemas/note.js +9 -0
  16. package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -4
  17. package/lib/chevre/repo/mongoose/schemas/product.js +2 -2
  18. package/lib/chevre/repo/note.d.ts +2 -9
  19. package/lib/chevre/repo/note.js +52 -18
  20. package/lib/chevre/repo/noteAboutOrder.d.ts +4 -0
  21. package/lib/chevre/repo/noteAboutOrder.js +17 -0
  22. package/lib/chevre/repo/product.js +15 -14
  23. package/lib/chevre/repo/productHasOfferCatalog.d.ts +43 -0
  24. package/lib/chevre/repo/productHasOfferCatalog.js +71 -0
  25. package/lib/chevre/repository.d.ts +5 -0
  26. package/lib/chevre/repository.js +14 -1
  27. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +1 -0
  28. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +1 -1
  29. package/lib/chevre/service/offer/event/searchOffersByIds.js +1 -1
  30. package/lib/chevre/service/offer/onEventChanged.js +2 -1
  31. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +19 -105
  32. package/lib/chevre/service/validation/validateEvent.js +1 -1
  33. package/package.json +3 -3
  34. package/example/src/chevre/unsetUnnecessaryFieldsInAction.ts +0 -50
  35. package/example/src/chevre/unsetUnnecessaryFieldsInTransaction.ts +0 -46
@@ -13,7 +13,7 @@ async function main() {
13
13
  const taskRepo = await chevre.repository.Task.createInstance(mongoose.connection);
14
14
 
15
15
  const events = <Pick<
16
- chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent>,
16
+ chevre.factory.event.screeningEvent.IEvent,
17
17
  'id' | 'typeOf' | 'startDate' | 'project'
18
18
  >[]>await eventRepo.projectEventFields(
19
19
  {
@@ -35,7 +35,7 @@ async function main() {
35
35
  await cursor.eachAsync(async (doc) => {
36
36
  i += 1;
37
37
  const event: Pick<
38
- chevre.factory.event.IEvent<chevre.factory.eventType.ScreeningEvent>,
38
+ chevre.factory.event.screeningEvent.IEvent,
39
39
  'startDate' | 'endDate' | 'project' | 'id'
40
40
  > = doc.toObject();
41
41
 
@@ -0,0 +1,34 @@
1
+ // tslint:disable:no-console no-magic-numbers
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ // tslint:disable-next-line:max-func-body-length
9
+ async function main() {
10
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
+
12
+ const noteRepo = await chevre.repository.Note.createInstance(mongoose.connection);
13
+ const notes = await noteRepo.findNotes(
14
+ {
15
+ limit: 10,
16
+ page: 1,
17
+ project: { id: { $eq: project.id } },
18
+ hasDigitalDocumentPermission: {
19
+ grantee: {
20
+ audienceType: {
21
+ $eq: chevre.factory.creativeWork.noteDigitalDocument.PermissionGranteeAudienceType.Public
22
+ }
23
+ }
24
+ }
25
+ },
26
+ ['about', 'identifier']
27
+ );
28
+ // tslint:disable-next-line:no-null-keyword
29
+ console.dir(notes, { depth: null });
30
+ }
31
+
32
+ main()
33
+ .then()
34
+ .catch(console.error);
@@ -15,7 +15,10 @@ async function main() {
15
15
  chevre.factory.creativeWork.noteDigitalDocument.INoteAboutProduct,
16
16
  'about' | 'creator' | 'identifier' | 'project' | 'provider' | 'text' | 'version' | 'hasDigitalDocumentPermission'
17
17
  > = {
18
- about: { id: '656038908b1cd5ce629f5992', typeOf: chevre.factory.product.ProductType.EventService },
18
+ about: {
19
+ id: '656038908b1cd5ce629f5992',
20
+ typeOf: chevre.factory.product.ProductType.EventService
21
+ },
19
22
  creator: { id: 'xxx', typeOf: chevre.factory.personType.Person },
20
23
  identifier: 'abcdefgh',
21
24
  project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
@@ -27,14 +30,13 @@ async function main() {
27
30
  };
28
31
  const createResult = await noteRepo.upsertNotesByIdentifier(
29
32
  [
30
- {
31
- $set: creatingNote
32
- // $unset: {}
33
- },
34
33
  {
35
34
  $set: creatingNote
36
35
  // $unset: {}
37
36
  }
37
+ // {
38
+ // $set: creatingNote
39
+ // }
38
40
  ],
39
41
  { update: false }
40
42
  );
@@ -46,6 +48,9 @@ async function main() {
46
48
  {
47
49
  $set: creatingNote
48
50
  }
51
+ // {
52
+ // $set: creatingNote
53
+ // }
49
54
  ],
50
55
  { update: true }
51
56
  );
@@ -0,0 +1,27 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ async function main() {
9
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
+
11
+ const productHasOfferCatalogRepo = await chevre.repository.ProductHasOfferCatalog.createInstance(mongoose.connection);
12
+
13
+ const offerCatalogs = (await productHasOfferCatalogRepo.findOfferCatalogs(
14
+ {
15
+ limit: 10,
16
+ page: 1,
17
+ project: { id: { $eq: project.id } },
18
+ product: { id: { $in: ['656038908b1cd5ce629f5992', '60c1c0031fb182000bed5eff'] } }
19
+ }
20
+ ));
21
+ // tslint:disable-next-line:no-null-keyword
22
+ console.dir(offerCatalogs, { depth: null });
23
+ }
24
+
25
+ main()
26
+ .then()
27
+ .catch(console.error);
@@ -0,0 +1,48 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ async function main() {
7
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
8
+
9
+ const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
+
11
+ const roleNames = [
12
+ chevre.factory.role.organizationRole.RoleName.InventoryManager
13
+ // chevre.factory.role.organizationRole.RoleName.SellersOwner,
14
+ // chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
15
+ ];
16
+ const permissions = [
17
+ 'admin.notes.*'
18
+ ];
19
+ for (const roleName of roleNames) {
20
+ for (const permission of permissions) {
21
+ const result = await roleRepo.addPermissionIfNotExists({
22
+ roleName: { $eq: roleName },
23
+ permission
24
+ });
25
+ console.log('permission added.', result, roleName);
26
+ }
27
+ }
28
+
29
+ // roleNames = [
30
+ // chevre.factory.role.organizationRole.RoleName.TicketClerk
31
+ // ];
32
+ // permissions = [
33
+ // 'admin.sellers.productOffers.read'
34
+ // ];
35
+ // for (const roleName of roleNames) {
36
+ // for (const permission of permissions) {
37
+ // const result = await roleRepo.addPermissionIfNotExists({
38
+ // roleName: { $eq: roleName },
39
+ // permission
40
+ // });
41
+ // console.log('permission added.', result, roleName);
42
+ // }
43
+ // }
44
+ }
45
+
46
+ main()
47
+ .then()
48
+ .catch(console.error);
@@ -8,29 +8,14 @@ async function main() {
8
8
 
9
9
  const roleRepo = await chevre.repository.Role.createInstance(mongoose.connection);
10
10
 
11
- let roleNames = [
11
+ const roleNames = [
12
12
  chevre.factory.role.organizationRole.RoleName.InventoryManager,
13
13
  chevre.factory.role.organizationRole.RoleName.SellersOwner,
14
- chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
15
- ];
16
- let permissions = [
17
- 'admin.sellers.productOffers.*'
18
- ];
19
- for (const roleName of roleNames) {
20
- for (const permission of permissions) {
21
- const result = await roleRepo.addPermissionIfNotExists({
22
- roleName: { $eq: roleName },
23
- permission
24
- });
25
- console.log('permission added.', result, roleName);
26
- }
27
- }
28
-
29
- roleNames = [
14
+ chevre.factory.role.organizationRole.RoleName.SellersInventoryManager,
30
15
  chevre.factory.role.organizationRole.RoleName.TicketClerk
31
16
  ];
32
- permissions = [
33
- 'admin.sellers.productOffers.read'
17
+ const permissions = [
18
+ 'admin.products.read'
34
19
  ];
35
20
  for (const roleName of roleNames) {
36
21
  for (const permission of permissions) {
@@ -41,6 +26,22 @@ async function main() {
41
26
  console.log('permission added.', result, roleName);
42
27
  }
43
28
  }
29
+
30
+ // roleNames = [
31
+ // chevre.factory.role.organizationRole.RoleName.TicketClerk
32
+ // ];
33
+ // permissions = [
34
+ // 'admin.sellers.productOffers.read'
35
+ // ];
36
+ // for (const roleName of roleNames) {
37
+ // for (const permission of permissions) {
38
+ // const result = await roleRepo.addPermissionIfNotExists({
39
+ // roleName: { $eq: roleName },
40
+ // permission
41
+ // });
42
+ // console.log('permission added.', result, roleName);
43
+ // }
44
+ // }
44
45
  }
45
46
 
46
47
  main()
@@ -9,18 +9,16 @@ import { chevre } from '../../../lib/index';
9
9
  async function main() {
10
10
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
11
11
 
12
- const eventRepo = await chevre.repository.Event.createInstance(mongoose.connection);
12
+ const noteRepo = await chevre.repository.NoteAboutOrder.createInstance(mongoose.connection);
13
13
 
14
14
  let updateResult: any;
15
15
 
16
- updateResult = await eventRepo.unsetUnnecessaryFields({
16
+ updateResult = await noteRepo.unsetUnnecessaryFields({
17
17
  filter: {
18
- // 'project.id': { $eq: '*' }
19
- // 'location.maximumAttendeeCapacity': { $exists: true },
20
- maximumPhysicalAttendeeCapacity: { $exists: true }
18
+ 'about.identifier': { $exists: true }
21
19
  },
22
- $unset: <any>{
23
- 'location.maximumAttendeeCapacity': 1
20
+ $unset: {
21
+ 'about.identifier': 1
24
22
  }
25
23
  });
26
24
  console.log(updateResult);
@@ -1,5 +1,5 @@
1
1
  import * as factory from '../factory';
2
- export type IMinimizedIndividualEvent = Pick<factory.event.IEvent<factory.eventType.ScreeningEvent>, 'project' | 'organizer' | 'id' | 'typeOf' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier' | 'maximumPhysicalAttendeeCapacity'>;
2
+ export type IMinimizedIndividualEvent = Pick<factory.event.screeningEvent.IEvent, 'project' | 'organizer' | 'id' | 'typeOf' | 'name' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'startDate' | 'superEvent' | 'offers' | 'coaInfo' | 'identifier' | 'maximumPhysicalAttendeeCapacity'>;
3
3
  /**
4
4
  * 興行イベントのsuperEventを作成する
5
5
  */
@@ -21,7 +21,7 @@ export interface IUpdateAggregateReservationParams {
21
21
  remainingAttendeeCapacity?: '';
22
22
  };
23
23
  }
24
- export type ISearchConditions = factory.event.ISearchConditions<factory.eventType.ScreeningEvent>;
24
+ export type ISearchConditions = factory.event.screeningEvent.ISearchConditions;
25
25
  interface IAggregationByStatus {
26
26
  eventCount: number;
27
27
  reservationCount: number;
@@ -44,17 +44,17 @@ interface IAggregateEvent {
44
44
  statuses: IStatus[];
45
45
  }
46
46
  export import IMinimizedIndividualEvent = EventFactory.IMinimizedIndividualEvent;
47
- type IKeyOfProjection = Exclude<keyof factory.event.IEvent<factory.eventType.ScreeningEvent>, 'id'> | 'aggregateOffer' | 'superEvent.location.id' | 'offers.itemOffered' | 'offers.itemOffered.id';
48
- type IKeyOfProjection4publicFields = Exclude<keyof factory.event.IEvent<factory.eventType.ScreeningEvent>, 'id' | 'offers'>;
47
+ type IKeyOfProjection = Exclude<keyof factory.event.screeningEvent.IEvent, 'id'> | 'aggregateOffer' | 'superEvent.location.id' | 'offers.itemOffered' | 'offers.itemOffered.id';
48
+ type IKeyOfProjection4publicFields = Exclude<keyof factory.event.screeningEvent.IEvent, 'id' | 'offers'>;
49
49
  /**
50
50
  * minimizedEvent検索時のprojection候補
51
51
  * add(2024-07-18~)
52
52
  */
53
53
  type IKeyOfProjection4minimizedEvent = Exclude<keyof IMinimizedIndividualEvent, 'additionalProperty' | 'id'> | 'superEvent.id' | 'location.branchCode' | 'superEvent.workPerformed.identifier' | 'superEvent.location.id' | 'offers.itemOffered' | 'offers.itemOffered.id' | 'offers.offeredThrough' | 'offers.unacceptedPaymentMethod' | 'offers.eligibleQuantity';
54
54
  type IUnset = {
55
- [key in keyof factory.event.IEvent<factory.eventType.ScreeningEvent>]?: 1;
55
+ [key in keyof factory.event.screeningEvent.IEvent]?: 1;
56
56
  };
57
- export type ICreatingEvent4ttts = Pick<factory.event.IAttributes<factory.eventType.ScreeningEvent>, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'name' | 'offers' | 'organizer' | 'project' | 'startDate' | 'superEvent' | 'typeOf'> & {
57
+ export type ICreatingEvent4ttts = Pick<factory.event.screeningEvent.IAttributes, 'additionalProperty' | 'doorTime' | 'endDate' | 'eventStatus' | 'location' | 'name' | 'offers' | 'organizer' | 'project' | 'startDate' | 'superEvent' | 'typeOf'> & {
58
58
  identifier: string;
59
59
  };
60
60
  /**
@@ -63,12 +63,12 @@ export type ICreatingEvent4ttts = Pick<factory.event.IAttributes<factory.eventTy
63
63
  export declare class EventRepo {
64
64
  private readonly eventModel;
65
65
  constructor(connection: Connection);
66
- static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): FilterQuery<factory.event.IEvent<factory.eventType.ScreeningEvent>>[];
66
+ static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): FilterQuery<factory.event.screeningEvent.IEvent>[];
67
67
  /**
68
68
  * 複数イベントを作成する
69
69
  */
70
70
  createManyEvents(params: {
71
- attributes: factory.event.IAttributes<factory.eventType.ScreeningEvent>[];
71
+ attributes: factory.event.screeningEvent.IAttributes[];
72
72
  expectsNoContent: boolean;
73
73
  }): Promise<string[] | void>;
74
74
  /**
@@ -77,7 +77,7 @@ export declare class EventRepo {
77
77
  * 存在すれば、特定の属性のみ更新する
78
78
  */
79
79
  upsertManyByAdditionalProperty(params: {
80
- events: factory.event.IAttributes<factory.eventType.ScreeningEvent>[];
80
+ events: factory.event.screeningEvent.IAttributes[];
81
81
  additionalPropertyFilter: {
82
82
  name: string;
83
83
  };
@@ -140,7 +140,7 @@ export declare class EventRepo {
140
140
  */
141
141
  saveEvent(params: {
142
142
  id?: string;
143
- attributes: factory.event.IAttributes<factory.eventType.ScreeningEvent>;
143
+ attributes: factory.event.screeningEvent.IAttributes;
144
144
  /**
145
145
  * ドキュメント作成時には無視される
146
146
  */
@@ -154,7 +154,7 @@ export declare class EventRepo {
154
154
  */
155
155
  saveManyEvents(params: {
156
156
  id: string;
157
- attributes: factory.event.IAttributes<factory.eventType.ScreeningEvent>;
157
+ attributes: factory.event.screeningEvent.IAttributes;
158
158
  $unset?: IUnset;
159
159
  upsert: boolean;
160
160
  }[]): Promise<void>;
@@ -169,7 +169,7 @@ export declare class EventRepo {
169
169
  /**
170
170
  * イベントを検索する(inclusion projection)
171
171
  */
172
- projectEventFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<Omit<factory.event.IEvent<factory.eventType.ScreeningEvent>, 'aggregateOffer'>[]>;
172
+ projectEventFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<Omit<factory.event.screeningEvent.IEvent, 'aggregateOffer'>[]>;
173
173
  /**
174
174
  * apiで公開属性を検索する(2024-10-13~)
175
175
  */
@@ -186,7 +186,7 @@ export declare class EventRepo {
186
186
  * offers.seller.makesOfferをavailableAtOrFromでfilterする
187
187
  */
188
188
  sellerMakesOfferAvailableAtIn?: string[];
189
- }): Promise<Omit<factory.event.IEvent<factory.eventType.ScreeningEvent>, 'aggregateOffer'>[]>;
189
+ }): Promise<Omit<factory.event.screeningEvent.IEvent, 'aggregateOffer'>[]>;
190
190
  /**
191
191
  * IDのみで検索する
192
192
  * projectionなし
@@ -205,7 +205,7 @@ export declare class EventRepo {
205
205
  $eq: string;
206
206
  };
207
207
  };
208
- }): Promise<Omit<factory.event.IEvent<factory.eventType.ScreeningEvent>, 'aggregateOffer'>>;
208
+ }): Promise<Omit<factory.event.screeningEvent.IEvent, 'aggregateOffer'>>;
209
209
  searchEventIds(params: ISearchConditions): Promise<string[]>;
210
210
  /**
211
211
  * 特定イベントから指定フィールドのみ取得する
@@ -360,7 +360,7 @@ export declare class EventRepo {
360
360
  };
361
361
  }): Promise<void>;
362
362
  unsetUnnecessaryFields(params: {
363
- filter: FilterQuery<factory.event.IEvent<factory.eventType.ScreeningEvent>>;
363
+ filter: FilterQuery<factory.event.screeningEvent.IEvent>;
364
364
  $unset: IUnset;
365
365
  }): Promise<import("mongoose").UpdateWriteOpResult>;
366
366
  aggregateEvent(params: {
@@ -261,7 +261,6 @@ class EventRepo {
261
261
  createManyEvents(params) {
262
262
  return __awaiter(this, void 0, void 0, function* () {
263
263
  const uniqid = yield Promise.resolve().then(() => require('uniqid'));
264
- // let docs: HydratedDocument<factory.event.IEvent<T>>[];
265
264
  const insertingDocs = params.attributes.map((p) => {
266
265
  return Object.assign({ _id: uniqid() }, p);
267
266
  });
@@ -1,6 +1,6 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
- type IDocTypeAsScreeningEvent = factory.event.IAttributes<factory.eventType.ScreeningEvent> & {
3
+ type IDocTypeAsScreeningEvent = factory.event.screeningEvent.IAttributes & {
4
4
  _id: string;
5
5
  aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
6
6
  };
@@ -3,11 +3,11 @@ import * as factory from '../../../factory';
3
3
  type IDocTypeAsEventSeries = factory.eventSeries.IAttributes & {
4
4
  _id: string;
5
5
  };
6
- export type IDocType = IDocTypeAsEventSeries;
6
+ type IDocType = IDocTypeAsEventSeries;
7
7
  type IModel = Model<IDocType>;
8
8
  type ISchemaDefinition = SchemaDefinition<IDocType>;
9
9
  type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
10
10
  declare const modelName = "EventSeries";
11
11
  declare const indexes: [d: IndexDefinition, o: IndexOptions][];
12
12
  declare function createSchema(): ISchema;
13
- export { createSchema, IModel, indexes, modelName };
13
+ export { createSchema, IDocType, IModel, indexes, modelName };
@@ -9,30 +9,21 @@ const settings_1 = require("../../../settings");
9
9
  const modelName = 'EventSeries';
10
10
  exports.modelName = modelName;
11
11
  const schemaDefinition = {
12
- project: {
13
- type: mongoose_1.SchemaTypes.Mixed,
14
- required: true
15
- },
16
- organizer: {
17
- type: mongoose_1.SchemaTypes.Mixed,
18
- required: true
19
- },
12
+ project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
13
+ organizer: { type: mongoose_1.SchemaTypes.Mixed, required: true },
20
14
  _id: String,
21
- typeOf: {
22
- type: String,
23
- required: true
24
- },
15
+ typeOf: { type: String, required: true },
25
16
  identifier: String,
26
17
  name: mongoose_1.SchemaTypes.Mixed,
27
18
  additionalProperty: mongoose_1.SchemaTypes.Mixed,
28
19
  alternativeHeadline: mongoose_1.SchemaTypes.Mixed,
29
20
  description: mongoose_1.SchemaTypes.Mixed,
30
21
  duration: String,
31
- endDate: Date,
22
+ endDate: { type: Date, required: true }, // required(2025-10-08~)
32
23
  eventStatus: String,
33
24
  headline: mongoose_1.SchemaTypes.Mixed,
34
25
  location: mongoose_1.SchemaTypes.Mixed,
35
- startDate: Date,
26
+ startDate: { type: Date, required: true }, // required(2025-10-08~)
36
27
  workPerformed: mongoose_1.SchemaTypes.Mixed,
37
28
  videoFormat: mongoose_1.SchemaTypes.Mixed,
38
29
  soundFormat: mongoose_1.SchemaTypes.Mixed,
@@ -85,6 +85,15 @@ const indexes = [
85
85
  [
86
86
  { identifier: 1, dateCreated: -1 },
87
87
  { name: 'identifier' }
88
+ ],
89
+ [
90
+ { 'hasDigitalDocumentPermission.grantee.audienceType': 1, dateCreated: -1 },
91
+ {
92
+ name: 'permissionGranteeAudienceType',
93
+ partialFilterExpression: {
94
+ 'hasDigitalDocumentPermission.grantee.audienceType': { $exists: true }
95
+ }
96
+ }
88
97
  ]
89
98
  // discontinue(2025-05-08~)
90
99
  // [
@@ -1,8 +1,8 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
- export type IDocTypeAsProduct = Omit<factory.product.IProduct, 'id'>;
4
- export interface IDocTypeAsProductOffer {
5
- offers?: factory.product.IOffer[];
3
+ type IDocTypeAsProduct = Omit<factory.product.IProduct, 'id'>;
4
+ interface IDocTypeAsProductOffer {
5
+ offers?: never;
6
6
  }
7
7
  type IDocType = IDocTypeAsProduct & IDocTypeAsProductOffer;
8
8
  type IModel = Model<IDocType>;
@@ -11,4 +11,4 @@ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocT
11
11
  declare const modelName = "Product";
12
12
  declare const indexes: [d: IndexDefinition, o: IndexOptions][];
13
13
  declare function createSchema(): ISchema;
14
- export { createSchema, IModel, indexes, modelName };
14
+ export { createSchema, IDocTypeAsProduct, IDocTypeAsProductOffer, IModel, indexes, modelName };
@@ -8,14 +8,14 @@ const settings_1 = require("../../../settings");
8
8
  const modelName = 'Product';
9
9
  exports.modelName = modelName;
10
10
  const schemaDefinition = {
11
- project: mongoose_1.SchemaTypes.Mixed,
11
+ project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
12
  typeOf: { type: String, required: true },
13
13
  additionalProperty: [mongoose_1.SchemaTypes.Mixed],
14
14
  availableChannel: mongoose_1.SchemaTypes.Mixed,
15
15
  description: mongoose_1.SchemaTypes.Mixed,
16
16
  hasOfferCatalog: mongoose_1.SchemaTypes.Mixed,
17
17
  name: mongoose_1.SchemaTypes.Mixed,
18
- offers: [mongoose_1.SchemaTypes.Mixed],
18
+ // offers: [SchemaTypes.Mixed], // discontinue(2025-10-15~)
19
19
  productID: { type: String, required: true },
20
20
  // provider: [SchemaTypes.Mixed], // 廃止(2024-04-12~)
21
21
  serviceOutput: mongoose_1.SchemaTypes.Mixed,
@@ -15,6 +15,8 @@ export declare class NoteRepo {
15
15
  })[]>;
16
16
  /**
17
17
  * メモ識別子をキーにして冪等置換
18
+ * 主題+識別子でユニーク必須
19
+ * 編集の場合、存在検証される
18
20
  */
19
21
  upsertNotesByIdentifier(params: {
20
22
  $set: Pick<INoteDigitalDocument, 'about' | 'creator' | 'identifier' | 'project' | 'provider' | 'text' | 'version' | 'hasDigitalDocumentPermission'> & {
@@ -32,15 +34,6 @@ export declare class NoteRepo {
32
34
  id: string;
33
35
  }[];
34
36
  } | void>;
35
- /**
36
- * 既知のメモIDリストからメモを削除する
37
- */
38
- deleteNotesByIds(params: {
39
- project: {
40
- id: string;
41
- };
42
- ids: string[];
43
- }): Promise<DeleteResult | void>;
44
37
  /**
45
38
  * 主題リソースから全メモを削除する
46
39
  */
@@ -35,7 +35,7 @@ class NoteRepo {
35
35
  this.noteModel = connection.model(note_1.modelName, (0, note_1.createSchema)());
36
36
  }
37
37
  static CREATE_MONGO_CONDITIONS(params) {
38
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
38
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
39
39
  const andConditions = [];
40
40
  const idIn = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$in;
41
41
  if (Array.isArray(idIn)) {
@@ -77,6 +77,10 @@ class NoteRepo {
77
77
  if (Array.isArray(identifierIn)) {
78
78
  andConditions.push({ identifier: { $in: identifierIn } });
79
79
  }
80
+ const audienceTypeEq = (_v = (_u = (_t = params.hasDigitalDocumentPermission) === null || _t === void 0 ? void 0 : _t.grantee) === null || _u === void 0 ? void 0 : _u.audienceType) === null || _v === void 0 ? void 0 : _v.$eq;
81
+ if (typeof audienceTypeEq === 'string') {
82
+ andConditions.push({ 'hasDigitalDocumentPermission.grantee.audienceType': { $exists: true, $eq: audienceTypeEq } });
83
+ }
80
84
  return andConditions;
81
85
  }
82
86
  findNotes(params, inclusion) {
@@ -107,25 +111,33 @@ class NoteRepo {
107
111
  }
108
112
  /**
109
113
  * メモ識別子をキーにして冪等置換
114
+ * 主題+識別子でユニーク必須
115
+ * 編集の場合、存在検証される
110
116
  */
117
+ // tslint:disable-next-line:max-func-body-length
111
118
  upsertNotesByIdentifier(params, options) {
112
119
  return __awaiter(this, void 0, void 0, function* () {
113
120
  const now = new Date();
114
121
  const { update } = options;
115
122
  const bulkWriteOps = [];
116
123
  const queryFilters = [];
124
+ let uniqueIdentifiers = [];
117
125
  if (Array.isArray(params)) {
118
126
  params.forEach(({ $set }) => {
119
127
  const { about, creator, identifier, project, provider, text, version, hasDigitalDocumentPermission } = $set;
120
- if (typeof identifier !== 'string' || identifier.length === 0) {
128
+ if (typeof about.id !== 'string' || about.id === '') {
129
+ throw new factory.errors.ArgumentNull('about.id');
130
+ }
131
+ if (typeof identifier !== 'string' || identifier === '') {
121
132
  throw new factory.errors.ArgumentNull('identifier');
122
133
  }
123
- if (typeof version !== 'string' || version.length === 0) {
134
+ if (typeof version !== 'string' || version === '') {
124
135
  throw new factory.errors.ArgumentNull('version');
125
136
  }
126
137
  if (typeof text !== 'string') {
127
138
  throw new factory.errors.ArgumentNull('text');
128
139
  }
140
+ uniqueIdentifiers.push(`${about.id}:${identifier}`);
129
141
  // リソースのユニークネスを保証するfilter
130
142
  const filter = {
131
143
  'project.id': { $eq: project.id },
@@ -167,6 +179,25 @@ class NoteRepo {
167
179
  });
168
180
  }
169
181
  if (bulkWriteOps.length > 0) {
182
+ // 主題+識別子でユニーク検証
183
+ uniqueIdentifiers = [...new Set(uniqueIdentifiers)];
184
+ if (uniqueIdentifiers.length !== bulkWriteOps.length) {
185
+ throw new factory.errors.Argument('identifier', '(about.id + identifier)s must be unique');
186
+ }
187
+ if (update === true) {
188
+ // 編集の場合、存在検証
189
+ const modifyingNotes = yield this.noteModel.find({ $or: queryFilters }, {
190
+ _id: 0,
191
+ id: { $toString: '$_id' }
192
+ })
193
+ .lean()
194
+ .exec();
195
+ // tslint:disable-next-line:no-console
196
+ console.log('NoteRepo.upsertNotesByIdentifier:', params.length, 'params ->', modifyingNotes.length, 'modifyingNotes found.', JSON.stringify(modifyingNotes));
197
+ if (modifyingNotes.length !== bulkWriteOps.length) {
198
+ throw new factory.errors.NotFound(factory.creativeWorkType.NoteDigitalDocument);
199
+ }
200
+ }
170
201
  const bulkWriteResult = yield this.noteModel.bulkWrite(bulkWriteOps, { ordered: false });
171
202
  // modifiedの場合upsertedIdsに含まれないので、idを検索する
172
203
  const modifiedNotes = yield this.noteModel.find({ $or: queryFilters }, {
@@ -179,21 +210,24 @@ class NoteRepo {
179
210
  }
180
211
  });
181
212
  }
182
- /**
183
- * 既知のメモIDリストからメモを削除する
184
- */
185
- deleteNotesByIds(params) {
186
- return __awaiter(this, void 0, void 0, function* () {
187
- const { project, ids } = params;
188
- if (Array.isArray(ids) && ids.length > 0) {
189
- return this.noteModel.deleteMany({
190
- 'project.id': { $eq: project.id },
191
- _id: { $in: ids }
192
- })
193
- .exec();
194
- }
195
- });
196
- }
213
+ // /**
214
+ // * 既知のメモIDリストからメモを削除する
215
+ // */
216
+ // public async deleteNotesByIds(params: {
217
+ // project: { id: string };
218
+ // ids: string[];
219
+ // }): Promise<DeleteResult | void> {
220
+ // const { project, ids } = params;
221
+ // if (Array.isArray(ids) && ids.length > 0) {
222
+ // return this.noteModel.deleteMany(
223
+ // {
224
+ // 'project.id': { $eq: project.id },
225
+ // _id: { $in: ids }
226
+ // }
227
+ // )
228
+ // .exec();
229
+ // }
230
+ // }
197
231
  /**
198
232
  * 主題リソースから全メモを削除する
199
233
  */
@@ -26,5 +26,9 @@ export declare class NoteAboutOrderRepo {
26
26
  id: string;
27
27
  attributes: Pick<INoteAboutOrder, 'text' | 'editor'>;
28
28
  }): Promise<void>;
29
+ unsetUnnecessaryFields(params: {
30
+ filter: FilterQuery<factory.creativeWork.noteDigitalDocument.INoteAboutOrder>;
31
+ $unset: any;
32
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
29
33
  }
30
34
  export {};
@@ -175,5 +175,22 @@ class NoteAboutOrderRepo {
175
175
  }
176
176
  });
177
177
  }
178
+ // public getCursor(conditions: FilterQuery<factory.creativeWork.noteDigitalDocument.INoteAboutOrder>, projection: any) {
179
+ // return this.noteModel.find(
180
+ // {
181
+ // ...conditions,
182
+ // 'about.typeOf': { $eq: factory.order.OrderType.Order }
183
+ // },
184
+ // projection
185
+ // )
186
+ // .sort({ dateCreated: factory.sortType.Ascending })
187
+ // .cursor();
188
+ // }
189
+ unsetUnnecessaryFields(params) {
190
+ return __awaiter(this, void 0, void 0, function* () {
191
+ return this.noteModel.updateMany(Object.assign(Object.assign({}, params.filter), { 'about.typeOf': { $eq: factory.order.OrderType.Order } }), { $unset: params.$unset }, { timestamps: false })
192
+ .exec();
193
+ });
194
+ }
178
195
  }
179
196
  exports.NoteAboutOrderRepo = NoteAboutOrderRepo;
@@ -48,7 +48,7 @@ class ProductRepo {
48
48
  }
49
49
  // tslint:disable-next-line:max-func-body-length
50
50
  static CREATE_MONGO_CONDITIONS(params) {
51
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
51
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
52
52
  // MongoDB検索条件
53
53
  const andConditions = [];
54
54
  const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
@@ -111,15 +111,16 @@ class ProductRepo {
111
111
  productID: { $regex: new RegExp(productIDRegex) }
112
112
  });
113
113
  }
114
- const offersElemMatch = (_m = params.offers) === null || _m === void 0 ? void 0 : _m.$elemMatch;
115
- if (offersElemMatch !== undefined && offersElemMatch !== null) {
116
- andConditions.push({
117
- offers: {
118
- $elemMatch: offersElemMatch
119
- }
120
- });
121
- }
122
- const serviceOutputTypeOfEq = (_p = (_o = params.serviceOutput) === null || _o === void 0 ? void 0 : _o.typeOf) === null || _p === void 0 ? void 0 : _p.$eq;
114
+ // discontinue product.offers
115
+ // const offersElemMatch = params.offers?.$elemMatch;
116
+ // if (offersElemMatch !== undefined && offersElemMatch !== null) {
117
+ // andConditions.push({
118
+ // offers: {
119
+ // $elemMatch: offersElemMatch
120
+ // }
121
+ // });
122
+ // }
123
+ const serviceOutputTypeOfEq = (_o = (_m = params.serviceOutput) === null || _m === void 0 ? void 0 : _m.typeOf) === null || _o === void 0 ? void 0 : _o.$eq;
123
124
  if (typeof serviceOutputTypeOfEq === 'string') {
124
125
  andConditions.push({
125
126
  'serviceOutput.typeOf': {
@@ -128,7 +129,7 @@ class ProductRepo {
128
129
  }
129
130
  });
130
131
  }
131
- const serviceOutputAmountCurrencyEq = (_s = (_r = (_q = params.serviceOutput) === null || _q === void 0 ? void 0 : _q.amount) === null || _r === void 0 ? void 0 : _r.currency) === null || _s === void 0 ? void 0 : _s.$eq;
132
+ const serviceOutputAmountCurrencyEq = (_r = (_q = (_p = params.serviceOutput) === null || _p === void 0 ? void 0 : _p.amount) === null || _q === void 0 ? void 0 : _q.currency) === null || _r === void 0 ? void 0 : _r.$eq;
132
133
  if (typeof serviceOutputAmountCurrencyEq === 'string') {
133
134
  andConditions.push({
134
135
  'serviceOutput.amount.currency': {
@@ -137,7 +138,7 @@ class ProductRepo {
137
138
  }
138
139
  });
139
140
  }
140
- const serviceTypeCodeValueEq = (_u = (_t = params.serviceType) === null || _t === void 0 ? void 0 : _t.codeValue) === null || _u === void 0 ? void 0 : _u.$eq;
141
+ const serviceTypeCodeValueEq = (_t = (_s = params.serviceType) === null || _s === void 0 ? void 0 : _s.codeValue) === null || _t === void 0 ? void 0 : _t.$eq;
141
142
  if (typeof serviceTypeCodeValueEq === 'string') {
142
143
  andConditions.push({
143
144
  'serviceType.codeValue': {
@@ -146,7 +147,7 @@ class ProductRepo {
146
147
  }
147
148
  });
148
149
  }
149
- const nameRegex = (_v = params.name) === null || _v === void 0 ? void 0 : _v.$regex;
150
+ const nameRegex = (_u = params.name) === null || _u === void 0 ? void 0 : _u.$regex;
150
151
  if (typeof nameRegex === 'string' && nameRegex.length > 0) {
151
152
  const nameRegexExp = new RegExp(nameRegex);
152
153
  andConditions.push({
@@ -156,7 +157,7 @@ class ProductRepo {
156
157
  ]
157
158
  });
158
159
  }
159
- const additionalPropertyElemMatchNameEq = (_w = params.additionalPropertyMatch) === null || _w === void 0 ? void 0 : _w.nameEq;
160
+ const additionalPropertyElemMatchNameEq = (_v = params.additionalPropertyMatch) === null || _v === void 0 ? void 0 : _v.nameEq;
160
161
  if (typeof additionalPropertyElemMatchNameEq === 'string') {
161
162
  andConditions.push({
162
163
  additionalProperty: {
@@ -0,0 +1,43 @@
1
+ import { Connection } from 'mongoose';
2
+ import * as factory from '../factory';
3
+ interface IOfferCatalogAsFindResult {
4
+ /**
5
+ * カタログID
6
+ */
7
+ id: string;
8
+ /**
9
+ * 対象オファー
10
+ */
11
+ aggregateElement: {
12
+ itemOffered: {
13
+ /**
14
+ * プロダクトID
15
+ */
16
+ id: string;
17
+ typeOf: factory.product.ProductType;
18
+ };
19
+ };
20
+ }
21
+ /**
22
+ * プロダクトオファーカタログリポジトリ
23
+ */
24
+ export declare class ProductHasOfferCatalogRepo {
25
+ private readonly productModel;
26
+ constructor(connection: Connection);
27
+ findOfferCatalogs(params: {
28
+ limit?: number;
29
+ page?: number;
30
+ project?: {
31
+ id?: {
32
+ $eq?: string;
33
+ };
34
+ };
35
+ product?: {
36
+ id?: {
37
+ $eq?: string;
38
+ $in?: string[];
39
+ };
40
+ };
41
+ }): Promise<IOfferCatalogAsFindResult[]>;
42
+ }
43
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.ProductHasOfferCatalogRepo = void 0;
13
+ const mongoose_1 = require("mongoose");
14
+ const factory = require("../factory");
15
+ const settings_1 = require("../settings");
16
+ const product_1 = require("./mongoose/schemas/product");
17
+ /**
18
+ * プロダクトオファーカタログリポジトリ
19
+ */
20
+ class ProductHasOfferCatalogRepo {
21
+ constructor(connection) {
22
+ this.productModel = connection.model(product_1.modelName, (0, product_1.createSchema)());
23
+ }
24
+ findOfferCatalogs(params) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ var _a, _b, _c, _d, _e, _f;
27
+ const matchStages = [];
28
+ const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
29
+ if (typeof projectIdEq === 'string') {
30
+ matchStages.push({ $match: { 'project.id': { $eq: projectIdEq } } });
31
+ }
32
+ const productIdEq = (_d = (_c = params.product) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$eq;
33
+ if (typeof productIdEq === 'string') {
34
+ matchStages.push({ $match: { _id: { $eq: new mongoose_1.Types.ObjectId(productIdEq) } } });
35
+ }
36
+ const productIdIn = (_f = (_e = params.product) === null || _e === void 0 ? void 0 : _e.id) === null || _f === void 0 ? void 0 : _f.$in;
37
+ if (Array.isArray(productIdIn)) {
38
+ matchStages.push({ $match: { _id: { $in: productIdIn.map((productId) => new mongoose_1.Types.ObjectId(productId)) } } });
39
+ }
40
+ const aggregate = this.productModel.aggregate([
41
+ {
42
+ $unwind: {
43
+ path: '$hasOfferCatalog.itemListElement'
44
+ }
45
+ },
46
+ ...matchStages,
47
+ { $sort: { productID: factory.sortType.Ascending } },
48
+ {
49
+ $project: {
50
+ _id: 0,
51
+ id: '$hasOfferCatalog.itemListElement.id',
52
+ aggregateElement: {
53
+ itemOffered: {
54
+ id: { $toString: '$_id' },
55
+ typeOf: '$typeOf'
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ]);
61
+ if (typeof params.limit === 'number' && params.limit > 0) {
62
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
63
+ aggregate.skip(params.limit * (page - 1))
64
+ .limit(params.limit);
65
+ }
66
+ return aggregate.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
67
+ .exec();
68
+ });
69
+ }
70
+ }
71
+ exports.ProductHasOfferCatalogRepo = ProductHasOfferCatalogRepo;
@@ -56,6 +56,7 @@ import type { SectionRepo } from './repo/place/section';
56
56
  import type { PotentialActionRepo } from './repo/potentialAction';
57
57
  import type { PriceSpecificationRepo } from './repo/priceSpecification';
58
58
  import type { ProductRepo } from './repo/product';
59
+ import type { ProductHasOfferCatalogRepo } from './repo/productHasOfferCatalog';
59
60
  import type { ProductModelRepo } from './repo/productModel';
60
61
  import type { ProductOfferRepo } from './repo/productOffer';
61
62
  import type { ProjectRepo } from './repo/project';
@@ -348,6 +349,10 @@ export type Product = ProductRepo;
348
349
  export declare namespace Product {
349
350
  function createInstance(...params: ConstructorParameters<typeof ProductRepo>): Promise<ProductRepo>;
350
351
  }
352
+ export type ProductHasOfferCatalog = ProductHasOfferCatalogRepo;
353
+ export declare namespace ProductHasOfferCatalog {
354
+ function createInstance(...params: ConstructorParameters<typeof ProductHasOfferCatalogRepo>): Promise<ProductHasOfferCatalogRepo>;
355
+ }
351
356
  export type ProductModel = ProductModelRepo;
352
357
  export declare namespace ProductModel {
353
358
  function createInstance(...params: ConstructorParameters<typeof ProductModelRepo>): Promise<ProductModelRepo>;
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.Permit = exports.Person = exports.paymentMethod = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Comment = exports.Authorization = exports.CategoryCode = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AdvanceBookingRequirement = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
13
- exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = void 0;
13
+ exports.WebSite = exports.rateLimit = exports.Trip = exports.TransactionProcess = exports.TransactionNumber = exports.Transaction = exports.Ticket = exports.Telemetry = exports.Task = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceOutputIdentifier = exports.ServiceOutput = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = exports.ProductModel = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = void 0;
14
14
  var AcceptedOffer;
15
15
  (function (AcceptedOffer) {
16
16
  let repo;
@@ -802,6 +802,19 @@ var Product;
802
802
  }
803
803
  Product.createInstance = createInstance;
804
804
  })(Product || (exports.Product = Product = {}));
805
+ var ProductHasOfferCatalog;
806
+ (function (ProductHasOfferCatalog) {
807
+ let repo;
808
+ function createInstance(...params) {
809
+ return __awaiter(this, void 0, void 0, function* () {
810
+ if (repo === undefined) {
811
+ repo = (yield Promise.resolve().then(() => require('./repo/productHasOfferCatalog'))).ProductHasOfferCatalogRepo;
812
+ }
813
+ return new repo(...params);
814
+ });
815
+ }
816
+ ProductHasOfferCatalog.createInstance = createInstance;
817
+ })(ProductHasOfferCatalog || (exports.ProductHasOfferCatalog = ProductHasOfferCatalog = {}));
805
818
  var ProductModel;
806
819
  (function (ProductModel) {
807
820
  let repo;
@@ -20,6 +20,7 @@ function verifyOfferedByToken(params) {
20
20
  try {
21
21
  result = yield new Promise((resolve, reject) => {
22
22
  jwt.verify(token, secret, {
23
+ algorithms: ['HS256'],
23
24
  issuer
24
25
  // ...(Array.isArray(params.audience)) ? { audience: params.audience } : undefined
25
26
  }, (err, decoded) => {
@@ -213,7 +213,7 @@ function getUnacceptedPaymentMethodByEvent(params) {
213
213
  */
214
214
  function searchEventTicketOffers(params) {
215
215
  return (repos) => __awaiter(this, void 0, void 0, function* () {
216
- const eventType = params.event.typeOf;
216
+ // const eventType = params.event.typeOf;
217
217
  // optimize projection(2024-07-17~)
218
218
  const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, [
219
219
  'project', 'typeOf', 'startDate',
@@ -197,7 +197,7 @@ function getUnacceptedPaymentMethodByEvent(params) {
197
197
  */
198
198
  function searchOffersByIds(params) {
199
199
  return (repos) => __awaiter(this, void 0, void 0, function* () {
200
- const eventType = params.event.typeOf;
200
+ // const eventType = params.event.typeOf;
201
201
  // optimize projection(2024-07-17~)
202
202
  const event = yield repos.event.projectEventFieldsById({ id: params.event.id }, [
203
203
  'project', 'typeOf', 'startDate',
@@ -160,7 +160,8 @@ function createInformTasks(params, setting) {
160
160
  );
161
161
  // 最適化(2024-03-25~)
162
162
  events4inform = screeningEventSeries4inform.map(({ project, organizer, typeOf, name, location, id, videoFormat, soundFormat, workPerformed, kanaName, eventStatus, endDate, startDate, additionalProperty, subtitleLanguage, dubLanguage, alternativeHeadline, description, duration, headline }) => {
163
- return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ project, organizer, typeOf, name, location, id, videoFormat, soundFormat, workPerformed, kanaName, eventStatus }, (endDate !== undefined) ? { endDate } : undefined), (startDate !== undefined) ? { startDate } : undefined), (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (subtitleLanguage !== undefined) ? {} : undefined), (dubLanguage !== undefined) ? { dubLanguage } : undefined), (alternativeHeadline !== undefined) ? { alternativeHeadline } : undefined), (description !== undefined) ? { description } : undefined), (typeof duration === 'string') ? { duration } : undefined), (headline !== undefined) ? { headline } : undefined);
163
+ return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ project, organizer, typeOf, name, location, id, videoFormat, soundFormat, workPerformed, kanaName, eventStatus,
164
+ endDate, startDate }, (Array.isArray(additionalProperty)) ? { additionalProperty } : undefined), (subtitleLanguage !== undefined) ? {} : undefined), (dubLanguage !== undefined) ? { dubLanguage } : undefined), (alternativeHeadline !== undefined) ? { alternativeHeadline } : undefined), (description !== undefined) ? { description } : undefined), (typeof duration === 'string') ? { duration } : undefined), (headline !== undefined) ? { headline } : undefined);
164
165
  });
165
166
  }
166
167
  if (events4inform.length > 0) {
@@ -4,105 +4,7 @@ exports.tour2creatingEvent = tour2creatingEvent;
4
4
  exports.schedule2tours = schedule2tours;
5
5
  const moment = require("moment-timezone");
6
6
  const factory = require("../../../../factory");
7
- // tslint:disable-next-line:max-func-body-length
8
- // function schedule2createEventParams(
9
- // schedule: factory.schedule.IEventWithSchedule,
10
- // createDate: Date
11
- // ): factory.event.screeningEvent.ICreateParams[] {
12
- // const eventServiceId = schedule.offers?.itemOffered?.id;
13
- // const makesOffer = schedule.offers?.seller?.makesOffer;
14
- // const applicationIds: string[] = (Array.isArray(makesOffer))
15
- // ? makesOffer.map(({ availableAtOrFrom }) => availableAtOrFrom.id)
16
- // : [];
17
- // const eventSeriesId = schedule.superEvent?.id;
18
- // if (typeof eventServiceId !== 'string' || eventServiceId === '') {
19
- // throw new factory.errors.NotFound('schedule.offers.itemOffered.id');
20
- // }
21
- // if (typeof eventSeriesId !== 'string' || eventSeriesId === '') {
22
- // throw new factory.errors.NotFound('schedule.superEvent.id');
23
- // }
24
- // // 引数情報取得
25
- // if (schedule.eventSchedule === undefined) {
26
- // throw new factory.errors.NotFound('eventSchedule');
27
- // }
28
- // const targetInfo = getTargetInfoByEventWithSchedule(schedule, createDate);
29
- // debug(targetInfo.length, 'targetInfos ->', targetInfo);
30
- // const createParams: factory.event.screeningEvent.ICreateParams[] = [];
31
- // for (const performanceInfo of targetInfo) {
32
- // const oldEventId = [
33
- // // tslint:disable-next-line:no-magic-numbers
34
- // performanceInfo.day.slice(-6),
35
- // workPerformedIdentifier,
36
- // movieTheater.branchCode,
37
- // screeningRoom.branchCode,
38
- // performanceInfo.start_time
39
- // ].join('');
40
- // const maxValue = movieTheater.offers?.eligibleQuantity?.maxValue;
41
- // const availabilityEnds: Date = moment(performanceInfo.end_date)
42
- // .tz('Asia/Tokyo')
43
- // .endOf('date')
44
- // .toDate();
45
- // const availabilityStarts: Date = moment(performanceInfo.start_date)
46
- // .tz('Asia/Tokyo')
47
- // .startOf('date')
48
- // // tslint:disable-next-line:no-magic-numbers
49
- // .add(-3, 'months')
50
- // .toDate();
51
- // const validThrough: Date = moment(performanceInfo.end_date)
52
- // .tz('Asia/Tokyo')
53
- // .endOf('date')
54
- // .toDate();
55
- // const validFrom: Date = moment(performanceInfo.start_date)
56
- // .tz('Asia/Tokyo')
57
- // .startOf('date')
58
- // // tslint:disable-next-line:no-magic-numbers
59
- // .add(-3, 'months')
60
- // .toDate();
61
- // // イベント作成
62
- // createParams.push({
63
- // eventStatus: factory.eventStatusType.EventScheduled,
64
- // doorTime: performanceInfo.door_time,
65
- // startDate: performanceInfo.start_date,
66
- // endDate: performanceInfo.end_date,
67
- // offers: {
68
- // eligibleQuantity: {
69
- // ...(typeof maxValue === 'number') ? { maxValue } : undefined // ひとまず全座席予約可能なように
70
- // },
71
- // itemOffered: {
72
- // // 興行ID追加(2022-09-01~)
73
- // id: eventServiceId,
74
- // serviceOutput: {
75
- // typeOf: factory.reservationType.EventReservation,
76
- // reservedTicket: {
77
- // typeOf: 'Ticket',
78
- // ticketedSeat: { typeOf: factory.placeType.Seat }
79
- // }
80
- // },
81
- // },
82
- // seller: {
83
- // // event.offersにseller.makesOfferを追加(2022-11-18~)
84
- // makesOffer: applicationIds.map((applicationId) => {
85
- // return {
86
- // typeOf: factory.offerType.Offer,
87
- // availableAtOrFrom: { id: applicationId }, // support no-array(2024-10-13~),
88
- // availabilityEnds,
89
- // availabilityStarts,
90
- // validFrom,
91
- // validThrough
92
- // };
93
- // })
94
- // }
95
- // },
96
- // // 旧フォーマットIDを追加特性に追加(2022-09-08~)
97
- // additionalProperty: [
98
- // { name: 'tourNumber', value: String(performanceInfo.tour_number) },
99
- // { name: 'oldEventId', value: oldEventId }
100
- // ],
101
- // identifier: oldEventId
102
- // });
103
- // }
104
- // return createParams;
105
- // }
7
+ const TIMEZONE = 'Asia/Tokyo';
106
8
  // tslint:disable-next-line:max-func-body-length
107
9
  function tour2creatingEvent(tour, movieTheater, screeningRoom, existingApplicationMembers, maxValue, eventService, screeningEventSeries, project) {
108
10
  var _a;
@@ -115,22 +17,34 @@ function tour2creatingEvent(tour, movieTheater, screeningRoom, existingApplicati
115
17
  screeningRoom.branchCode,
116
18
  tour.start_time
117
19
  ].join('');
20
+ // 00:00:00で再実装(2025-10-09~)
21
+ // const availabilityEnds: Date = moment(tour.end_date)
22
+ // .tz(TIMEZONE)
23
+ // .endOf('date')
24
+ // .toDate();
118
25
  const availabilityEnds = moment(tour.end_date)
119
- .tz('Asia/Tokyo')
120
- .endOf('date')
26
+ .tz(TIMEZONE)
27
+ .startOf('date')
28
+ .add(1, 'day')
121
29
  .toDate();
122
30
  const availabilityStarts = moment(tour.start_date)
123
- .tz('Asia/Tokyo')
31
+ .tz(TIMEZONE)
124
32
  .startOf('date')
125
33
  // tslint:disable-next-line:no-magic-numbers
126
34
  .add(-3, 'months')
127
35
  .toDate();
36
+ // 00:00:00で再実装(2025-10-09~)
37
+ // const validThrough: Date = moment(tour.end_date)
38
+ // .tz(TIMEZONE)
39
+ // .endOf('date')
40
+ // .toDate();
128
41
  const validThrough = moment(tour.end_date)
129
- .tz('Asia/Tokyo')
130
- .endOf('date')
42
+ .tz(TIMEZONE)
43
+ .startOf('date')
44
+ .add(1, 'day')
131
45
  .toDate();
132
46
  const validFrom = moment(tour.start_date)
133
- .tz('Asia/Tokyo')
47
+ .tz(TIMEZONE)
134
48
  .startOf('date')
135
49
  // tslint:disable-next-line:no-magic-numbers
136
50
  .add(-3, 'months')
@@ -16,7 +16,7 @@ exports.validateEvent = validateEvent;
16
16
  function validateEvent(__) {
17
17
  return (__2) => __awaiter(this, void 0, void 0, function* () {
18
18
  // const event: Pick<factory.event.screeningEvent.IEvent, 'id' | 'startDate'> =
19
- // await repos.event.projectEventFieldsById<factory.eventType.ScreeningEvent>(
19
+ // await repos.event.projectEventFieldsById(
20
20
  // { id: params.id },
21
21
  // ['startDate']
22
22
  // );
package/package.json CHANGED
@@ -11,8 +11,8 @@
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": "5.0.0-alpha.0",
15
- "@cinerino/sdk": "12.5.0-alpha.1",
14
+ "@chevre/factory": "5.1.0-alpha.3",
15
+ "@cinerino/sdk": "12.5.0-alpha.9",
16
16
  "@motionpicture/coa-service": "9.6.0",
17
17
  "@motionpicture/gmo-service": "5.4.0-alpha.1",
18
18
  "@sendgrid/client": "8.1.4",
@@ -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": "23.0.0-alpha.0"
118
+ "version": "23.0.0-alpha.10"
119
119
  }
@@ -1,50 +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 DAYS = 365;
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const now = new Date();
12
- let updateResult: any;
13
-
14
- const actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
15
-
16
- const startIndex = 8760;
17
- // tslint:disable-next-line:no-magic-numbers
18
- const hours = (DAYS * 24) + startIndex;
19
- // tslint:disable-next-line:no-increment-decrement no-magic-numbers
20
- for (let index = startIndex; index < hours; index++) {
21
- // for (let index = 0; index < hours; index++) {
22
- updateResult = await actionRepo.unsetUnnecessaryFields({
23
- filter: {
24
- // _id: { $eq: '667379e7be9a532411c29424' },
25
- typeOf: { $eq: chevre.factory.actionType.CheckAction },
26
- 'object.typeOf': { $exists: true, $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket },
27
- actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
28
- startDate: {
29
- $gte: moment(now)
30
- .add(-(index + 1), 'hours')
31
- .toDate(),
32
- $lt: moment(now)
33
- .add(-index, 'hours')
34
- .toDate()
35
- }
36
- },
37
- $unset: {
38
- 'result.purchaseNumberAuthIn': 1,
39
- 'result.purchaseNumberAuthResult': 1
40
- }
41
- });
42
- console.log('unset processed.', updateResult, -(index + 1), 'hours', -index, 'hours');
43
- }
44
-
45
- console.log(DAYS, 'days processed');
46
- }
47
-
48
- main()
49
- .then()
50
- .catch(console.error);
@@ -1,46 +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 DAYS = 500;
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
10
-
11
- const now = new Date();
12
- let updateResult: any;
13
-
14
- const transactionRepo = await chevre.repository.Transaction.createInstance(mongoose.connection);
15
-
16
- // tslint:disable-next-line:no-magic-numbers
17
- const hours = DAYS * 24;
18
- // tslint:disable-next-line:no-increment-decrement no-magic-numbers
19
- for (let index = 0; index < hours; index++) {
20
- updateResult = await transactionRepo.unsetUnnecessaryFields({
21
- filter: {
22
- // _id: { $eq: '649a7654ff1c885bcc40bbb7' },
23
- typeOf: { $eq: chevre.factory.transactionType.PlaceOrder },
24
- status: { $eq: chevre.factory.transactionStatusType.Confirmed },
25
- startDate: {
26
- $gte: moment(now)
27
- .add(-(index + 1), 'hours')
28
- .toDate(),
29
- $lt: moment(now)
30
- .add(-index, 'hours')
31
- .toDate()
32
- }
33
- },
34
- $unset: {
35
- 'result.order.acceptedOffers': 1
36
- }
37
- });
38
- console.log('unset processed.', updateResult, -(index + 1), 'hours', -index, 'hours');
39
- }
40
-
41
- console.log(DAYS, 'days processed');
42
- }
43
-
44
- main()
45
- .then()
46
- .catch(console.error);