@chevre/domain 21.13.0-alpha.7 → 21.13.0-alpha.9

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 (43) hide show
  1. package/lib/chevre/repo/creativeWork.d.ts +7 -1
  2. package/lib/chevre/repo/creativeWork.js +36 -8
  3. package/lib/chevre/repo/event.d.ts +4 -4
  4. package/lib/chevre/repo/reservation.d.ts +2 -2
  5. package/lib/chevre/service/event.d.ts +3 -0
  6. package/lib/chevre/service/event.js +24 -3
  7. package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
  8. package/lib/chevre/settings.d.ts +0 -1
  9. package/lib/chevre/settings.js +1 -5
  10. package/package.json +2 -2
  11. package/example/src/chevre/assetTransaction/searchGMOTrade.ts +0 -27
  12. package/example/src/chevre/countDelayedTasks.ts +0 -22
  13. package/example/src/chevre/countDelayedTransactions.ts +0 -60
  14. package/example/src/chevre/countMoneyTransferTransaction.ts +0 -36
  15. package/example/src/chevre/countOffers.ts +0 -32
  16. package/example/src/chevre/createDeleteTransactionTasks.ts +0 -108
  17. package/example/src/chevre/createDeleteTransactionTasksIfNotExist.ts +0 -98
  18. package/example/src/chevre/createDeleteTransactionTasksOfDeletedPeople.ts +0 -126
  19. package/example/src/chevre/createManyEventsIfNotExist.ts +0 -365
  20. package/example/src/chevre/iam/searchMemberOfIdsByMemberId.ts +0 -31
  21. package/example/src/chevre/iam/searchProjectIdsByMemberId.ts +0 -32
  22. package/example/src/chevre/offer/searchAllByIdsAndOfferCatalogId.ts +0 -34
  23. package/example/src/chevre/offer/searchEventTicketOffers.ts +0 -54
  24. package/example/src/chevre/offer/searchOffersByCatalog.ts +0 -40
  25. package/example/src/chevre/processPay.ts +0 -90
  26. package/example/src/chevre/processRegisterMembership.ts +0 -110
  27. package/example/src/chevre/processRegisterPaymentCard.ts +0 -98
  28. package/example/src/chevre/processReserve.ts +0 -114
  29. package/example/src/chevre/publishConfirmationNumber.ts +0 -27
  30. package/example/src/chevre/publishPermitOwnershipInfoToken.ts +0 -56
  31. package/example/src/chevre/reIndex.ts +0 -25
  32. package/example/src/chevre/redisConfig.ts +0 -32
  33. package/example/src/chevre/saveTasks.ts +0 -41
  34. package/example/src/chevre/searchAbortedTasks.ts +0 -34
  35. package/example/src/chevre/searchAcceptedOfferIds.ts +0 -23
  36. package/example/src/chevre/searchOffersFromAggregateOffer.ts +0 -168
  37. package/example/src/chevre/searchOrdersWithUnwoundOffers.ts +0 -35
  38. package/example/src/chevre/searchReservationNumbersByOrderNumbers.ts +0 -58
  39. package/example/src/chevre/task/executeTasks.ts +0 -26
  40. package/example/src/chevre/unsetContainsInPlaceFromMovieTheater.ts +0 -41
  41. package/example/src/chevre/updateOfferCatalogs.ts +0 -40
  42. package/example/src/chevre/updateTransaction.ts +0 -38
  43. package/example/src/playOnMoment.ts +0 -24
@@ -1,54 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
- import * as redis from 'redis';
4
-
5
- import { chevre } from '../../../../lib/index';
6
-
7
- // const PROJECT_ID = process.env.PROJECT_ID;
8
-
9
- async function main() {
10
- const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
11
- socket: {
12
- port: Number(<string>process.env.REDIS_PORT),
13
- host: <string>process.env.REDIS_HOST
14
- },
15
- password: <string>process.env.REDIS_KEY
16
- });
17
- await client.connect();
18
-
19
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
20
-
21
- const eventRepo = new chevre.repository.Event(mongoose.connection);
22
- const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
23
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
24
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
25
- const offerRateLimitRepo = new chevre.repository.rateLimit.Offer(client);
26
- const productRepo = new chevre.repository.Product(mongoose.connection);
27
-
28
- const { ticketOffers } = await chevre.service.offer.event.searchEventTicketOffers({
29
- event: { id: 'ale6qiedq' },
30
- onlyValid: true,
31
- includedInDataCatalog: { id: '' },
32
- priceSpecification: {},
33
- validateOfferRateLimit: true,
34
- addSortIndex: true,
35
- useIncludeInDataCatalog: true,
36
- limit: 100,
37
- page: 1
38
- // ...(typeof availableAtId === 'string') ? { store: { id: availableAtId } } : undefined
39
- })({
40
- event: eventRepo,
41
- offer: offerRepo,
42
- offerCatalog: offerCatalogRepo,
43
- offerRateLimit: offerRateLimitRepo,
44
- priceSpecification: priceSpecificationRepo,
45
- product: productRepo
46
- });
47
- console.log(ticketOffers);
48
- console.log(ticketOffers.map((o) => o.sortIndex));
49
- console.log(ticketOffers.length);
50
- }
51
-
52
- main()
53
- .then(console.log)
54
- .catch(console.error);
@@ -1,40 +0,0 @@
1
- // tslint:disable:no-console
2
- // import * as redis from 'redis';
3
- import * as mongoose from 'mongoose';
4
-
5
- import { chevre } from '../../../../lib/index';
6
-
7
- async function main() {
8
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
-
10
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
11
-
12
- const { offers, sortedOfferIds } = await offerRepo.searchByOfferCatalogIdWithSortIndex({
13
- limit: 10,
14
- page: 1,
15
- // ids: ['xx', 'xxx', '1001', '901'],
16
- offerCatalog: {
17
- id: '0001',
18
- isOfferCatalogItem: false
19
- },
20
- excludeAppliesToMovieTicket: false,
21
- useIncludeInDataCatalog: false,
22
- priceSpecification: {
23
- // appliesToMovieTicket: {
24
- // serviceOutput: { typeOf: { $eq: 'SurfRock' } },
25
- // serviceType: { $exists: true }
26
- // }
27
- }
28
- });
29
- // console.log(offers);
30
- console.log(offers.map((offer) => {
31
- const sortIndex = sortedOfferIds.findIndex((s) => s === offer.id);
32
-
33
- return `${offer.project?.id} ${offer.identifier} ${offer.priceSpecification?.price} ${offer.name?.ja} ${offer.id} ${offer.offerIndex} ${sortIndex}`;
34
- }));
35
- console.log(offers.length);
36
- }
37
-
38
- main()
39
- .then(console.log)
40
- .catch(console.error);
@@ -1,90 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- import * as redis from 'redis';
5
-
6
- import { chevre } from '../../../lib/index';
7
-
8
- const project = { id: String(process.env.PROJECT_ID) };
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
13
- socket: {
14
- port: Number(<string>process.env.REDIS_PORT),
15
- host: <string>process.env.REDIS_HOST
16
- },
17
- password: <string>process.env.REDIS_KEY
18
- });
19
- await client.connect();
20
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
21
-
22
- const accountingReportRepo = new chevre.repository.AccountingReport(mongoose.connection);
23
- const actionRepo = new chevre.repository.Action(mongoose.connection);
24
- const productRepo = new chevre.repository.Product(mongoose.connection);
25
- const projectRepo = new chevre.repository.Project(mongoose.connection);
26
- const sellerRepo = new chevre.repository.Seller(mongoose.connection);
27
- const taskRepo = new chevre.repository.Task(mongoose.connection);
28
- const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
29
- const eventRepo = new chevre.repository.Event(mongoose.connection);
30
- const personRepo = new chevre.repository.Person({ userPoolId: 'xxx' });
31
- const transactionNumberRepo = new chevre.repository.TransactionNumber(client);
32
-
33
- const { transactionNumber } = await transactionNumberRepo.publishByTimestamp({ startDate: new Date() });
34
-
35
- const transaction = await chevre.service.assetTransaction.pay.start(
36
- {
37
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
38
- typeOf: chevre.factory.assetTransactionType.Pay,
39
- transactionNumber: transactionNumber,
40
- agent: { typeOf: chevre.factory.personType.Person, name: 'サンプル決済者名称', id: '' },
41
- expires: moment()
42
- .add(1, 'minute')
43
- .toDate(),
44
- object: {
45
- typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard,
46
- id: 'xxx',
47
- paymentMethod: {
48
- amount: 1,
49
- identifier: 'CreditCard',
50
- method: '1',
51
- creditCard: {
52
- memberId: 'xxx',
53
- cardSeq: 91
54
- // cardPass?: string;
55
- }
56
-
57
- }
58
- },
59
- recipient: {
60
- typeOf: chevre.factory.organizationType.Corporation,
61
- id: '5d0abf30ac3fb200198ebb2c',
62
- name: 'xx'
63
- }
64
- },
65
- {
66
- useCheckMovieTicketBeforePay: true,
67
- useCheckByIdentifierIfNotYet: true,
68
- searchTrade4accountId: false
69
- }
70
- )({
71
- accountingReport: accountingReportRepo,
72
- action: actionRepo,
73
- event: eventRepo,
74
- person: personRepo,
75
- product: productRepo,
76
- project: projectRepo,
77
- seller: sellerRepo,
78
- assetTransaction: assetTransactionRepo,
79
- task: taskRepo
80
- });
81
- console.log(transaction);
82
- console.log('transaction started');
83
-
84
- }
85
-
86
- main()
87
- .then(() => {
88
- console.log('success!');
89
- })
90
- .catch(console.error);
@@ -1,110 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- // import * as redis from 'redis';
5
-
6
- import { chevre } from '../../../lib/index';
7
-
8
- const project = { id: String(process.env.PROJECT_ID) };
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
-
14
- const accountRepo = new chevre.repository.Account(mongoose.connection);
15
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
16
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
17
- const productRepo = new chevre.repository.Product(mongoose.connection);
18
- const serviceOutputRepo = new chevre.repository.ServiceOutput(mongoose.connection);
19
- const projectRepo = new chevre.repository.Project(mongoose.connection);
20
- // const taskRepo = new chevre.repository.Task(mongoose.connection);
21
- const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
22
-
23
- // プロダクト検索
24
- const products = await productRepo.search(
25
- {
26
- project: { id: { $eq: project.id } },
27
- typeOf: { $eq: chevre.factory.product.ProductType.MembershipService }
28
- },
29
- [],
30
- []
31
- );
32
- console.log(products);
33
-
34
- const product = products[0];
35
- console.log(product);
36
-
37
- const identifier = `CIN${(new Date()).valueOf()}`;
38
- const transaction = await chevre.service.assetTransaction.registerService.start({
39
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
40
- typeOf: chevre.factory.assetTransactionType.RegisterService,
41
- transactionNumber: identifier,
42
- agent: { typeOf: chevre.factory.personType.Person, name: 'サンプル決済者名称', id: '' },
43
- expires: moment()
44
- .add(1, 'minute')
45
- .toDate(),
46
- object: [
47
- {
48
- typeOf: chevre.factory.offerType.Offer,
49
- // 7iri85wk5ggjsmg
50
- // id: '7iri85wk5ggf685',
51
- id: '7k9f3ht34',
52
- itemOffered: {
53
- // project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
54
- // typeOf: product.typeOf,
55
- id: product.id,
56
- pointAward: {
57
- // typeOf: chevre.factory.actionType.MoneyTransfer,
58
- // description?: string;
59
- // recipient?: any;
60
- toLocation: { identifier: '72001740002', issuedThrough: { id: 'xxx' } },
61
- recipient: { typeOf: 'Person', name: 'サンプル受取人', id: 'sampleId' }
62
- },
63
- serviceOutput: {
64
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
65
- typeOf: chevre.factory.permit.PermitType.Permit,
66
- additionalProperty: [{ name: 'sampleName', value: 'sampleValue' }],
67
- name: 'サンプルメンバーシップ',
68
- issuedBy: {
69
- typeOf: 'MovieTheater',
70
- name: 'サンプルシアター'
71
- }
72
- }
73
- }
74
- }
75
- ]
76
- })({
77
- account: accountRepo,
78
- offer: offerRepo,
79
- offerCatalog: offerCatalogRepo,
80
- product: productRepo,
81
- serviceOutput: serviceOutputRepo,
82
- project: projectRepo,
83
- assetTransaction: assetTransactionRepo
84
- });
85
- console.log(transaction);
86
- console.log('transaction started');
87
-
88
- await chevre.service.assetTransaction.registerService.confirm({
89
- id: transaction.id,
90
- endDate: moment('2020-06-10T00:00:00Z')
91
- .toDate()
92
- })({
93
- assetTransaction: assetTransactionRepo
94
- });
95
- console.log('transaction confirmed');
96
- // await chevre.service.assetTransaction.registerProgramMembership.cancel({
97
- // object: {
98
- // membershipNumber: membershipNumber
99
- // }
100
- // })({
101
- // transaction: assetTransactionRepo
102
- // });
103
- // console.log('transaction canceled');
104
- }
105
-
106
- main()
107
- .then(() => {
108
- console.log('success!');
109
- })
110
- .catch(console.error);
@@ -1,98 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- // import * as redis from 'redis';
5
-
6
- import { chevre } from '../../../lib/index';
7
-
8
- const project = { id: String(process.env.PROJECT_ID) };
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
-
14
- const accountRepo = new chevre.repository.Account(mongoose.connection);
15
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
16
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
17
- const productRepo = new chevre.repository.Product(mongoose.connection);
18
- const serviceOutputRepo = new chevre.repository.ServiceOutput(mongoose.connection);
19
- const projectRepo = new chevre.repository.Project(mongoose.connection);
20
- // const taskRepo = new chevre.repository.Task(mongoose.connection);
21
- const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
22
-
23
- // プロダクト検索
24
- const products = await productRepo.search(
25
- {
26
- project: { id: { $eq: project.id } },
27
- typeOf: { $eq: chevre.factory.product.ProductType.PaymentCard }
28
- },
29
- [],
30
- []
31
- );
32
- console.log(products);
33
-
34
- const product = products[0];
35
- console.log(product);
36
-
37
- const transactionNumber = `CIN${(new Date()).valueOf()}`;
38
- const identifier = transactionNumber;
39
- const accessCode = '123';
40
- const transaction = await chevre.service.assetTransaction.registerService.start({
41
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
42
- typeOf: chevre.factory.assetTransactionType.RegisterService,
43
- transactionNumber: transactionNumber,
44
- agent: { typeOf: chevre.factory.personType.Person, name: 'サンプル決済者名称', id: '' },
45
- expires: moment()
46
- .add(1, 'minute')
47
- .toDate(),
48
- object: [
49
- {
50
- typeOf: chevre.factory.offerType.Offer,
51
- id: '7k740xps8',
52
- itemOffered: {
53
- // project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
54
- // typeOf: product.typeOf,
55
- id: product.id,
56
- serviceOutput: {
57
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
58
- typeOf: chevre.factory.permit.PermitType.Permit,
59
- identifier: `${identifier}00`,
60
- accessCode: accessCode,
61
- name: 'プリペ'
62
- }
63
- }
64
- }
65
- ]
66
- })({
67
- account: accountRepo,
68
- offer: offerRepo,
69
- offerCatalog: offerCatalogRepo,
70
- product: productRepo,
71
- serviceOutput: serviceOutputRepo,
72
- project: projectRepo,
73
- assetTransaction: assetTransactionRepo
74
- });
75
- console.log(transaction);
76
- console.log('transaction started');
77
-
78
- await chevre.service.assetTransaction.registerService.confirm({
79
- id: transaction.id
80
- })({
81
- assetTransaction: assetTransactionRepo
82
- });
83
- console.log('transaction confirmed');
84
- // await chevre.service.assetTransaction.registerProgramMembership.cancel({
85
- // object: {
86
- // membershipNumber: membershipNumber
87
- // }
88
- // })({
89
- // transaction: assetTransactionRepo
90
- // });
91
- // console.log('transaction canceled');
92
- }
93
-
94
- main()
95
- .then(() => {
96
- console.log('success!');
97
- })
98
- .catch(console.error);
@@ -1,114 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- import * as redis from 'redis';
5
-
6
- import { chevre } from '../../../lib/index';
7
-
8
- const project = { id: String(process.env.PROJECT_ID) };
9
-
10
- // tslint:disable-next-line:max-func-body-length
11
- async function main() {
12
- const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
13
- socket: {
14
- port: Number(<string>process.env.REDIS_PORT),
15
- host: <string>process.env.REDIS_HOST
16
- },
17
- password: <string>process.env.REDIS_KEY
18
- });
19
- await client.connect();
20
- await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
21
-
22
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
23
- const offerCatalogRepo = new chevre.repository.OfferCatalog(mongoose.connection);
24
- const productRepo = new chevre.repository.Product(mongoose.connection);
25
- // const serviceOutputRepo = new chevre.repository.ServiceOutput(mongoose.connection);
26
- const projectRepo = new chevre.repository.Project(mongoose.connection);
27
- const taskRepo = new chevre.repository.Task(mongoose.connection);
28
- const assetTransactionRepo = new chevre.repository.AssetTransaction(mongoose.connection);
29
- const placeRepo = new chevre.repository.Place(mongoose.connection);
30
- const priceSpecRepo = new chevre.repository.PriceSpecification(mongoose.connection);
31
- const reservationRepo = new chevre.repository.Reservation(mongoose.connection);
32
- const eventRepo = new chevre.repository.Event(mongoose.connection);
33
- const itemAvailabilityRepo = new chevre.repository.StockHolder(client, mongoose.connection);
34
- const offerRateLimitRepo = new chevre.repository.rateLimit.Offer(client);
35
-
36
- const identifier = `CIN${(new Date()).valueOf()}`;
37
- const transaction = await chevre.service.assetTransaction.reserve.start({
38
- project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
39
- typeOf: chevre.factory.assetTransactionType.Reserve,
40
- transactionNumber: identifier,
41
- agent: { typeOf: chevre.factory.personType.Person, name: 'サンプル決済者名称', id: '' },
42
- expires: moment()
43
- .add(1, 'minute')
44
- .toDate(),
45
- object: {
46
- acceptedOffer: [
47
- {
48
- id: '1008',
49
- itemOffered: {
50
- serviceOutput: {
51
- // project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
52
- typeOf: chevre.factory.reservationType.EventReservation,
53
- reservedTicket: {
54
- typeOf: 'Ticket',
55
- ticketedSeat: {
56
- typeOf: chevre.factory.placeType.Seat,
57
- seatNumber: 'B-2',
58
- seatSection: 'Default',
59
- seatRow: ''
60
- }
61
- }
62
- // name: 'サンプルメンバーシップ',
63
- }
64
- }
65
- }
66
- ],
67
- reservationFor: { id: 'ckuz8uj0c' }
68
- },
69
- validateEvent: false,
70
- validateEventOfferPeriod: false,
71
- validateAppliesToMovieTicket: true,
72
- stockHoldUntilDaysAfterEventEnd: 31,
73
- useHoldStockByTransactionNumber: true
74
- })({
75
- stockHolder: itemAvailabilityRepo,
76
- event: eventRepo,
77
- offer: offerRepo,
78
- offerCatalog: offerCatalogRepo,
79
- offerRateLimit: offerRateLimitRepo,
80
- product: productRepo,
81
- place: placeRepo,
82
- priceSpecification: priceSpecRepo,
83
- project: projectRepo,
84
- reservation: reservationRepo,
85
- // serviceOutput: serviceOutputRepo,
86
- task: taskRepo,
87
- assetTransaction: assetTransactionRepo
88
- });
89
- console.log(transaction);
90
- console.log('transaction started');
91
-
92
- // await chevre.service.assetTransaction.registerService.confirm({
93
- // id: transaction.id,
94
- // endDate: moment('2020-06-10T00:00:00Z')
95
- // .toDate()
96
- // })({
97
- // assetTransaction: assetTransactionRepo
98
- // });
99
- // console.log('transaction confirmed');
100
- // await chevre.service.assetTransaction.registerProgramMembership.cancel({
101
- // object: {
102
- // membershipNumber: membershipNumber
103
- // }
104
- // })({
105
- // transaction: assetTransactionRepo
106
- // });
107
- // console.log('transaction canceled');
108
- }
109
-
110
- main()
111
- .then(() => {
112
- console.log('success!');
113
- })
114
- .catch(console.error);
@@ -1,27 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as redis from 'redis';
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
- const client = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
11
- socket: {
12
- host: process.env.REDIS_HOST,
13
- port: Number(process.env.REDIS_PORT)
14
- },
15
- password: process.env.REDIS_KEY
16
- });
17
- await client.connect();
18
-
19
- const confirmationNumberRepo = new chevre.repository.ConfirmationNumber(client);
20
- await confirmationNumberRepo.publish({ orderDate: new Date() });
21
- }
22
-
23
- main()
24
- .then(() => {
25
- console.log('success!');
26
- })
27
- .catch(console.error);
@@ -1,56 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as jwt from 'jsonwebtoken';
3
- import { chevre } from '../../../lib/index';
4
-
5
- function getToken(params: {
6
- expiresIn: number;
7
- payload: chevre.factory.authorization.IOwnershipInfoAsObject;
8
- }) {
9
- return async (__: {}) => {
10
- // const now = new Date();
11
-
12
- // const data = authorization.object;
13
-
14
- return new Promise<string>((resolve, reject) => {
15
- // 所有権を暗号化する
16
- jwt.sign(
17
- params.payload,
18
- chevre.credentials.jwt.secret,
19
- // params.secret,
20
- {
21
- issuer: chevre.credentials.jwt.issuer,
22
- // issuer: params.issuer,
23
- expiresIn: params.expiresIn
24
- },
25
- (err, encoded) => {
26
- if (err instanceof Error) {
27
- reject(err);
28
- } else {
29
- if (typeof encoded !== 'string') {
30
- reject(new chevre.factory.errors.ServiceUnavailable('authorization.object cannot be signed unexpectedly'));
31
- } else {
32
- resolve(encoded);
33
- }
34
- }
35
- }
36
- );
37
- });
38
- };
39
- }
40
-
41
- getToken({
42
- expiresIn: 2678400,
43
- payload: {
44
- typeOf: 'OwnershipInfo',
45
- id: '',
46
- typeOfGood: {
47
- typeOf: chevre.factory.permit.PermitType.Permit,
48
- identifier: 'xxxxxxxxxxxx',
49
- issuedThrough: { id: '64f193ad5e79fe8a06ca3156', typeOf: chevre.factory.service.paymentService.PaymentServiceType.CreditCard }
50
- }
51
- }
52
- })({})
53
- .then((token) => {
54
- console.log('token:', token);
55
- })
56
- .catch(console.error);
@@ -1,25 +0,0 @@
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);
8
-
9
- const priceSpecificationRepo = new chevre.repository.PriceSpecification(mongoose.connection);
10
- const result = await priceSpecificationRepo.reIndex();
11
- console.log(result);
12
- }
13
-
14
- main()
15
- .then()
16
- .catch(console.error);
17
- // setInterval(
18
- // () => {
19
- // main()
20
- // .then()
21
- // .catch(console.error);
22
- // },
23
- // // tslint:disable-next-line:no-magic-numbers
24
- // 60000
25
- // );
@@ -1,32 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as redis from 'redis';
3
-
4
- // const project = { id: String(process.env.PROJECT_ID) };
5
-
6
- // tslint:disable-next-line:max-func-body-length
7
- async function main() {
8
- const client = redis.createClient({
9
- socket: {
10
- host: process.env.REDIS_HOST,
11
- port: Number(process.env.REDIS_PORT)
12
- },
13
- password: process.env.REDIS_KEY
14
- });
15
- await client.connect();
16
-
17
- console.log(await client.info());
18
-
19
- const key = 'sampleTest';
20
- const ttl = 60;
21
- const results = await client.multi()
22
- .setNX(key, '1')
23
- .expire(key, ttl)
24
- .exec();
25
- console.log('results:', results);
26
- }
27
-
28
- main()
29
- .then(() => {
30
- console.log('success!');
31
- })
32
- .catch(console.error);