@chevre/domain 23.0.0-alpha.25 → 23.0.0-alpha.27

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.
@@ -4,7 +4,7 @@ import * as mongoose from 'mongoose';
4
4
 
5
5
  import { chevre } from '../../../../lib/index';
6
6
 
7
- const project = { id: String(process.env.PROJECT_ID) };
7
+ // const project = { id: String(process.env.PROJECT_ID) };
8
8
  const PROPERTY_NAME = 'createId';
9
9
 
10
10
  async function additionalProperty2identifier(raw: string) {
@@ -42,7 +42,7 @@ async function main() {
42
42
  const cursor = eventRepo.getCursor(
43
43
  {
44
44
  // _id: { $eq: '68f5d32176b5f6b689ff24a6' },
45
- 'project.id': { $eq: project.id },
45
+ // 'project.id': { $eq: project.id },
46
46
  'additionalProperty.name': { $exists: true, $eq: PROPERTY_NAME }
47
47
  },
48
48
  {
@@ -80,6 +80,10 @@ async function main() {
80
80
 
81
81
  if (alreadyMigrated) {
82
82
  validateIdentifier(eventIdentifier);
83
+ // 追加特性から生成された識別子に一致するはず
84
+ if (identifierMustBe !== eventIdentifier) {
85
+ throw new Error(`${identifierMustBe} !== ${eventIdentifier} ${event.id}, ${i}`);
86
+ }
83
87
  console.log(
84
88
  'already migrated.', event.project.id, eventIdentifier, additionalPropertyValue, event.id, event.startDate, i);
85
89
  } else {
@@ -0,0 +1,15 @@
1
+ // tslint:disable:no-console no-magic-numbers
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 movieTicketTypeRepo = await chevre.repository.MovieTicketType.createInstance(mongoose.connection);
10
+ await movieTicketTypeRepo.migrateCollections(mongoose.connection);
11
+ }
12
+
13
+ main()
14
+ .then()
15
+ .catch(console.error);
@@ -3,13 +3,8 @@ import * as factory from '../factory';
3
3
  type IUnset = {
4
4
  [key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image' | 'paymentMethod'>]?: 1;
5
5
  };
6
- export type CategorySetIdentifierExceptMovieTicketType = Exclude<factory.categoryCode.CategorySetIdentifier, factory.categoryCode.CategorySetIdentifier.MovieTicketType>;
7
- export type ICategoryCodeExceptMovieTicketType = Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf'> & {
8
- inCodeSet: {
9
- typeOf: 'CategoryCodeSet';
10
- identifier: CategorySetIdentifierExceptMovieTicketType;
11
- };
12
- };
6
+ export type CategorySetIdentifierExceptMovieTicketType = factory.categoryCode.CategorySetIdentifier;
7
+ export type ICategoryCodeExceptMovieTicketType = Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf' | 'inCodeSet'>;
13
8
  type IKeyOfProjection = keyof factory.categoryCode.ICategoryCode;
14
9
  type IKeyOfProjectionExceptMovieTicketType = keyof ICategoryCodeExceptMovieTicketType;
15
10
  /**
@@ -37,7 +37,7 @@ class CategoryCodeRepo {
37
37
  }
38
38
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
39
39
  static CREATE_MONGO_CONDITIONS(params, options) {
40
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
40
+ var _a, _b, _c, _d, _e, _f, _g;
41
41
  const excludeMovieTicketType = (options === null || options === void 0 ? void 0 : options.excludeMovieTicketType) === true;
42
42
  const andConditions = [];
43
43
  if (excludeMovieTicketType) {
@@ -133,25 +133,25 @@ class CategoryCodeRepo {
133
133
  }
134
134
  });
135
135
  }
136
- const paymentMethodTypeOfEq = (_h = (_g = params.paymentMethod) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$eq;
137
- if (typeof paymentMethodTypeOfEq === 'string') {
138
- andConditions.push({
139
- 'paymentMethod.typeOf': {
140
- $exists: true,
141
- $eq: paymentMethodTypeOfEq
142
- }
143
- });
144
- }
145
- const paymentMethodTypeOfIn = (_k = (_j = params.paymentMethod) === null || _j === void 0 ? void 0 : _j.typeOf) === null || _k === void 0 ? void 0 : _k.$in;
146
- if (Array.isArray(paymentMethodTypeOfIn)) {
147
- andConditions.push({
148
- 'paymentMethod.typeOf': {
149
- $exists: true,
150
- $in: paymentMethodTypeOfIn
151
- }
152
- });
153
- }
154
- const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
136
+ // const paymentMethodTypeOfEq = params.paymentMethod?.typeOf?.$eq;
137
+ // if (typeof paymentMethodTypeOfEq === 'string') {
138
+ // andConditions.push({
139
+ // 'paymentMethod.typeOf': {
140
+ // $exists: true,
141
+ // $eq: paymentMethodTypeOfEq
142
+ // }
143
+ // });
144
+ // }
145
+ // const paymentMethodTypeOfIn = params.paymentMethod?.typeOf?.$in;
146
+ // if (Array.isArray(paymentMethodTypeOfIn)) {
147
+ // andConditions.push({
148
+ // 'paymentMethod.typeOf': {
149
+ // $exists: true,
150
+ // $in: paymentMethodTypeOfIn
151
+ // }
152
+ // });
153
+ // }
154
+ const additionalPropertyElemMatch = (_g = params.additionalProperty) === null || _g === void 0 ? void 0 : _g.$elemMatch;
155
155
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
156
156
  andConditions.push({
157
157
  additionalProperty: {
@@ -126,7 +126,7 @@ const indexes = [
126
126
  unique: true,
127
127
  name: 'uniqueByCodeValueAndPaymentMethod',
128
128
  partialFilterExpression: {
129
- 'inCodeSet.identifier': { $eq: factory.categoryCode.CategorySetIdentifier.MovieTicketType },
129
+ 'inCodeSet.identifier': { $eq: factory.movieTicketType.CategorySetIdentifier.MovieTicketType },
130
130
  'paymentMethod.typeOf': { $exists: true }
131
131
  }
132
132
  }
@@ -0,0 +1,11 @@
1
+ import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
+ import * as factory from '../../../factory';
3
+ type IMovieTicketType = Pick<factory.movieTicketType.IMovieTicketType, 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf' | 'inCodeSet' | 'paymentMethod'>;
4
+ type IDocType = factory.categoryCode.ICategoryCode;
5
+ type IModel = Model<IDocType>;
6
+ type ISchemaDefinition = SchemaDefinition<IDocType>;
7
+ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
8
+ declare const modelName = "MovieTicketType";
9
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
10
+ declare function createSchema(): ISchema;
11
+ export { createSchema, IModel, IMovieTicketType, indexes, modelName };
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelName = exports.indexes = void 0;
4
+ exports.createSchema = createSchema;
5
+ const mongoose_1 = require("mongoose");
6
+ const writeConcern_1 = require("../writeConcern");
7
+ const settings_1 = require("../../../settings");
8
+ const modelName = 'MovieTicketType';
9
+ exports.modelName = modelName;
10
+ const schemaDefinition = {
11
+ project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
+ typeOf: { type: String, required: true },
13
+ // additionalProperty: [SchemaTypes.Mixed],
14
+ color: String,
15
+ image: String,
16
+ codeValue: { type: String, required: true },
17
+ inCodeSet: { type: mongoose_1.SchemaTypes.Mixed, required: true },
18
+ name: mongoose_1.SchemaTypes.Mixed,
19
+ paymentMethod: { type: mongoose_1.SchemaTypes.Mixed, required: true }
20
+ };
21
+ const schemaOptions = {
22
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
23
+ autoCreate: false,
24
+ collection: 'movieTicketTypes',
25
+ id: true,
26
+ read: settings_1.MONGO_READ_PREFERENCE,
27
+ writeConcern: writeConcern_1.writeConcern,
28
+ strict: true,
29
+ strictQuery: false,
30
+ timestamps: false, // 2024-08-22~
31
+ versionKey: false, // 2024-08-22~
32
+ toJSON: {
33
+ getters: false,
34
+ virtuals: false,
35
+ minimize: false,
36
+ versionKey: false
37
+ },
38
+ toObject: {
39
+ getters: false,
40
+ virtuals: true,
41
+ minimize: false,
42
+ versionKey: false
43
+ }
44
+ };
45
+ const indexes = [
46
+ [
47
+ { codeValue: 1 },
48
+ { name: 'codeValue' }
49
+ ],
50
+ [
51
+ { 'project.id': 1, codeValue: 1 },
52
+ { name: 'projectId' }
53
+ ],
54
+ [
55
+ { 'paymentMethod.typeOf': 1, codeValue: 1 },
56
+ { name: 'paymentMethodTypeOf' }
57
+ ],
58
+ [
59
+ { 'inCodeSet.identifier': 1, codeValue: 1 },
60
+ { name: 'inCodeSetIdentifier' }
61
+ ],
62
+ [
63
+ {
64
+ 'project.id': 1,
65
+ 'paymentMethod.typeOf': 1,
66
+ codeValue: 1
67
+ },
68
+ {
69
+ unique: true,
70
+ name: 'uniqueByCodeValueAndPaymentMethod'
71
+ }
72
+ ],
73
+ [
74
+ { 'name.ja': 1, codeValue: 1 },
75
+ {
76
+ name: 'nameJa',
77
+ partialFilterExpression: {
78
+ 'name.ja': { $exists: true }
79
+ }
80
+ }
81
+ ],
82
+ [
83
+ { 'name.en': 1, codeValue: 1 },
84
+ {
85
+ name: 'nameEn',
86
+ partialFilterExpression: {
87
+ 'name.en': { $exists: true }
88
+ }
89
+ }
90
+ ]
91
+ ];
92
+ exports.indexes = indexes;
93
+ /**
94
+ * 決済カード区分スキーマ
95
+ */
96
+ let schema;
97
+ function createSchema() {
98
+ if (schema === undefined) {
99
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
100
+ if (settings_1.MONGO_AUTO_INDEX) {
101
+ indexes.forEach((indexParams) => {
102
+ schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
103
+ });
104
+ }
105
+ }
106
+ return schema;
107
+ }
@@ -1,19 +1,8 @@
1
1
  import { AnyExpression, Connection, FilterQuery } from 'mongoose';
2
+ import { IMovieTicketType } from './mongoose/schemas/movieTicketTypes';
2
3
  import * as factory from '../factory';
3
4
  type IUnset = {
4
- [key in keyof Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'color' | 'image'>]?: 1;
5
- };
6
- type IMovieTicketType = Pick<factory.categoryCode.ICategoryCode, 'additionalProperty' | 'codeValue' | 'color' | 'id' | 'image' | 'name' | 'project' | 'typeOf'> & {
7
- paymentMethod: {
8
- /**
9
- * 決済カード区分の場合、対応決済方法区分
10
- */
11
- typeOf: string;
12
- };
13
- inCodeSet: {
14
- typeOf: 'CategoryCodeSet';
15
- identifier: factory.categoryCode.CategorySetIdentifier.MovieTicketType;
16
- };
5
+ [key in keyof Pick<factory.movieTicketType.IMovieTicketType, 'color' | 'image'>]?: 1;
17
6
  };
18
7
  type IKeyOfProjection = keyof IMovieTicketType;
19
8
  /**
@@ -22,17 +11,17 @@ type IKeyOfProjection = keyof IMovieTicketType;
22
11
  export declare class MovieTicketTypeRepo {
23
12
  private readonly categoryCodeModel;
24
13
  constructor(connection: Connection);
25
- static CREATE_MONGO_CONDITIONS(params: factory.categoryCode.ISearchConditions): FilterQuery<IMovieTicketType>[];
14
+ static CREATE_MONGO_CONDITIONS(params: factory.movieTicketType.ISearchConditions): FilterQuery<IMovieTicketType>[];
26
15
  static CREATE_AGGREGATE_PROJECTION(inclusion: IKeyOfProjection[]): {
27
16
  [field: string]: AnyExpression;
28
17
  };
29
18
  /**
30
19
  * 決済カード区分検索
31
20
  */
32
- projectMovieTicketTypeFields(params: Omit<factory.categoryCode.ISearchConditions, 'inCodeSet'> & {
21
+ projectMovieTicketTypeFields(params: Omit<factory.movieTicketType.ISearchConditions, 'inCodeSet'> & {
33
22
  inCodeSet?: {
34
23
  identifier?: {
35
- $eq?: factory.categoryCode.CategorySetIdentifier.MovieTicketType;
24
+ $eq?: factory.movieTicketType.CategorySetIdentifier.MovieTicketType;
36
25
  };
37
26
  };
38
27
  },
@@ -64,5 +53,6 @@ export declare class MovieTicketTypeRepo {
64
53
  id: string;
65
54
  };
66
55
  }): Promise<void>;
56
+ migrateCollections(connection: Connection): Promise<void>;
67
57
  }
68
58
  export {};
@@ -24,25 +24,26 @@ exports.MovieTicketTypeRepo = void 0;
24
24
  // tslint:disable-next-line:no-implicit-dependencies
25
25
  const mongoose_1 = require("mongoose");
26
26
  const categoryCode_1 = require("./mongoose/schemas/categoryCode");
27
+ const movieTicketTypes_1 = require("./mongoose/schemas/movieTicketTypes");
27
28
  const factory = require("../factory");
28
29
  const settings_1 = require("../settings");
29
30
  const AVAILABLE_PROJECT_FIELDS = [
30
- 'additionalProperty', 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'paymentMethod', 'project', 'typeOf'
31
+ 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'paymentMethod', 'project', 'typeOf'
31
32
  ];
32
33
  /**
33
34
  * 決済カード区分リポジトリ
34
35
  */
35
36
  class MovieTicketTypeRepo {
36
37
  constructor(connection) {
37
- this.categoryCodeModel = connection.model(categoryCode_1.modelName, (0, categoryCode_1.createSchema)());
38
+ this.categoryCodeModel = connection.model(movieTicketTypes_1.modelName, (0, movieTicketTypes_1.createSchema)());
38
39
  }
39
40
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
40
41
  static CREATE_MONGO_CONDITIONS(params) {
41
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
42
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
42
43
  const andConditions = [
43
44
  {
44
45
  'inCodeSet.identifier': {
45
- $eq: factory.categoryCode.CategorySetIdentifier.MovieTicketType
46
+ $eq: factory.movieTicketType.CategorySetIdentifier.MovieTicketType
46
47
  }
47
48
  }
48
49
  ];
@@ -138,15 +139,15 @@ class MovieTicketTypeRepo {
138
139
  }
139
140
  });
140
141
  }
141
- const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
142
- if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
143
- andConditions.push({
144
- additionalProperty: {
145
- $exists: true,
146
- $elemMatch: additionalPropertyElemMatch
147
- }
148
- });
149
- }
142
+ // const additionalPropertyElemMatch = params.additionalProperty?.$elemMatch;
143
+ // if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
144
+ // andConditions.push({
145
+ // additionalProperty: {
146
+ // $exists: true,
147
+ // $elemMatch: additionalPropertyElemMatch
148
+ // }
149
+ // });
150
+ // }
150
151
  return andConditions;
151
152
  }
152
153
  static CREATE_AGGREGATE_PROJECTION(inclusion) {
@@ -155,7 +156,7 @@ class MovieTicketTypeRepo {
155
156
  id: { $toString: '$_id' },
156
157
  project: '$project',
157
158
  typeOf: '$typeOf',
158
- additionalProperty: '$additionalProperty',
159
+ // additionalProperty: '$additionalProperty',
159
160
  color: '$color',
160
161
  image: '$image',
161
162
  codeValue: '$codeValue',
@@ -258,5 +259,35 @@ class MovieTicketTypeRepo {
258
259
  .exec();
259
260
  });
260
261
  }
262
+ // tslint:disable-next-line:prefer-function-over-method
263
+ migrateCollections(connection) {
264
+ return __awaiter(this, void 0, void 0, function* () {
265
+ const oldCategoryCodeModel = connection.model(categoryCode_1.modelName, (0, categoryCode_1.createSchema)());
266
+ const movieTicketTypeModel = connection.model(movieTicketTypes_1.modelName, (0, movieTicketTypes_1.createSchema)());
267
+ const cursor = oldCategoryCodeModel.find({
268
+ 'inCodeSet.identifier': { $eq: factory.movieTicketType.CategorySetIdentifier.MovieTicketType }
269
+ })
270
+ .sort({ codeValue: factory.sortType.Ascending })
271
+ .cursor();
272
+ let i = 0;
273
+ yield cursor.eachAsync((doc) => __awaiter(this, void 0, void 0, function* () {
274
+ i += 1;
275
+ const movieTicketType = doc.toObject();
276
+ const { additionalProperty } = movieTicketType, docWithoutAdditinalProperty = __rest(movieTicketType, ["additionalProperty"]);
277
+ // tslint:disable-next-line:no-console
278
+ console.log('upserting...', doc);
279
+ const result = yield movieTicketTypeModel.findOneAndReplace({ _id: { $eq: doc._id } }, docWithoutAdditinalProperty, {
280
+ upsert: true,
281
+ projection: { _id: 1 }
282
+ })
283
+ .exec();
284
+ // await additionalPropertyRepo.save({ attributes: additionalProperty });
285
+ // tslint:disable-next-line:no-console
286
+ console.log('upserted', result, movieTicketType.id, movieTicketType.project.id, movieTicketType.codeValue);
287
+ }));
288
+ // tslint:disable-next-line:no-console
289
+ console.log(i, 'docs checked');
290
+ });
291
+ }
261
292
  }
262
293
  exports.MovieTicketTypeRepo = MovieTicketTypeRepo;
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.2.0-alpha.2",
15
- "@cinerino/sdk": "12.6.0-alpha.5",
14
+ "@chevre/factory": "5.2.0-alpha.3",
15
+ "@cinerino/sdk": "12.7.0-alpha.0",
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.25"
118
+ "version": "23.0.0-alpha.27"
119
119
  }