@chevre/domain 22.11.0-alpha.4 → 22.11.0-alpha.40
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.
- package/example/src/chevre/aggregation/aggregateOrderOfCustomer.ts +21 -10
- package/example/src/chevre/aggregation/aggregateTasks.ts +41 -0
- package/example/src/chevre/assetTransaction/processReserve.ts +0 -1
- package/example/src/chevre/checkCustomerAttributesLength.ts +109 -0
- package/example/src/chevre/notifyAbortedTasksByEmail.ts +1 -1
- package/example/src/chevre/reIndex.ts +1 -1
- package/example/src/chevre/roles/addAdminPermissionIfNotExists.ts +132 -0
- package/example/src/chevre/roles/addDefaultPermissionIfNotExists.ts +37 -0
- package/example/src/chevre/roles/addEventOfferPermissionIfNotExists.ts +27 -0
- package/example/src/chevre/roles/addPermissionIfNotExists.ts +39 -6
- package/example/src/chevre/roles/addProjectCreatorRole.ts +48 -0
- package/example/src/chevre/roles/assignGlobalRoles.ts +72 -0
- package/example/src/chevre/roles/findPermissions.ts +84 -0
- package/example/src/chevre/roles/findRoleNames.ts +117 -0
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +38 -0
- package/example/src/chevre/roles/removePermissionFromAPIRoles.ts +46 -0
- package/example/src/chevre/roles/removePermissionIfExists.ts +39 -0
- package/example/src/chevre/searchEventSeats.ts +1 -1
- package/example/src/chevre/searchProducts.ts +28 -0
- package/example/src/chevre/settings/addSettings.ts +31 -17
- package/example/src/chevre/task/countPotentiallyRunning.ts +41 -0
- package/example/src/chevre/task/countTasks.ts +51 -0
- package/example/src/chevre/{deleteRunsAtPassedCertainPeriod.ts → task/deleteRunsAtPassedCertainPeriod.ts} +4 -3
- package/example/src/chevre/task/deleteUnexpectedTasks.ts +23 -0
- package/example/src/chevre/task/emitRunning.ts +89 -0
- package/example/src/chevre/unsetUnnecessaryFields.ts +8 -5
- package/example/src/idaas/auth0/adminApplications.ts +183 -0
- package/example/src/idaas/auth0/getToken.ts +55 -0
- package/example/src/idaas/auth0/getTokenByPrivateKeyJWT.ts +84 -0
- package/example/src/regex.ts +31 -0
- package/lib/chevre/eventEmitter/task.d.ts +29 -6
- package/lib/chevre/index.d.ts +0 -2
- package/lib/chevre/index.js +0 -10
- package/lib/chevre/repo/confirmationNumber.d.ts +0 -3
- package/lib/chevre/repo/confirmationNumber.js +12 -47
- package/lib/chevre/repo/identity.d.ts +11 -33
- package/lib/chevre/repo/identity.js +10 -15
- package/lib/chevre/repo/member.d.ts +22 -4
- package/lib/chevre/repo/member.js +81 -27
- package/lib/chevre/repo/mongoose/schemas/identity.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/member/global.d.ts +14 -0
- package/lib/chevre/repo/mongoose/schemas/member/global.js +82 -0
- package/lib/chevre/repo/mongoose/schemas/product.js +9 -0
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +15 -0
- package/lib/chevre/repo/mongoose/schemas/setting.js +1 -0
- package/lib/chevre/repo/mongoose/schemas/task.js +9 -0
- package/lib/chevre/repo/order.d.ts +17 -2
- package/lib/chevre/repo/order.js +47 -8
- package/lib/chevre/repo/orderNumber.d.ts +0 -3
- package/lib/chevre/repo/orderNumber.js +10 -44
- package/lib/chevre/repo/pendingReservation.js +1 -0
- package/lib/chevre/repo/product.js +12 -17
- package/lib/chevre/repo/role.d.ts +16 -4
- package/lib/chevre/repo/role.js +71 -32
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -3
- package/lib/chevre/repo/serviceOutputIdentifier.js +10 -27
- package/lib/chevre/repo/setting.d.ts +5 -10
- package/lib/chevre/repo/setting.js +4 -7
- package/lib/chevre/repo/stockHolder.d.ts +4 -27
- package/lib/chevre/repo/stockHolder.js +163 -186
- package/lib/chevre/repo/task.d.ts +58 -38
- package/lib/chevre/repo/task.js +126 -296
- package/lib/chevre/repo/transaction.js +10 -10
- package/lib/chevre/repo/transactionNumber.d.ts +0 -3
- package/lib/chevre/repo/transactionNumber.js +10 -44
- package/lib/chevre/repo/transactionNumberCounter.d.ts +0 -10
- package/lib/chevre/repo/transactionNumberCounter.js +34 -29
- package/lib/chevre/service/assetTransaction/cancelReservation/start.d.ts +1 -1
- package/lib/chevre/service/assetTransaction/registerService.js +4 -0
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +19 -16
- package/lib/chevre/service/code.d.ts +5 -28
- package/lib/chevre/service/code.js +3 -79
- package/lib/chevre/service/iam.d.ts +17 -7
- package/lib/chevre/service/iam.js +26 -6
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.d.ts +15 -0
- package/lib/chevre/service/notification/notifyAbortedTasksByEmail.js +38 -0
- package/lib/chevre/service/notification.d.ts +2 -1
- package/lib/chevre/service/notification.js +3 -1
- package/lib/chevre/service/offer/product.js +4 -0
- package/lib/chevre/service/order/confirmPayTransaction.d.ts +6 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderProcessing/processOrder.js +3 -3
- package/lib/chevre/service/task/acceptCOAOffer.d.ts +1 -1
- package/lib/chevre/service/task/acceptCOAOffer.js +6 -5
- package/lib/chevre/service/task/aggregateOffers.d.ts +1 -1
- package/lib/chevre/service/task/aggregateOffers.js +1 -1
- package/lib/chevre/service/task/aggregateOnSystem.d.ts +4 -2
- package/lib/chevre/service/task/aggregateScreeningEvent.d.ts +1 -1
- package/lib/chevre/service/task/aggregateScreeningEvent.js +1 -1
- package/lib/chevre/service/task/authorizePayment.d.ts +1 -1
- package/lib/chevre/service/task/authorizePayment.js +7 -6
- package/lib/chevre/service/task/cancelMoneyTransfer.d.ts +1 -1
- package/lib/chevre/service/task/cancelPendingReservation.d.ts +1 -1
- package/lib/chevre/service/task/cancelPendingReservation.js +1 -1
- package/lib/chevre/service/task/cancelReservation.d.ts +1 -1
- package/lib/chevre/service/task/cancelReservation.js +1 -1
- package/lib/chevre/service/task/checkMovieTicket.d.ts +1 -1
- package/lib/chevre/service/task/checkMovieTicket.js +4 -3
- package/lib/chevre/service/task/checkResource.d.ts +1 -1
- package/lib/chevre/service/task/checkResource.js +1 -1
- package/lib/chevre/service/task/confirmMoneyTransfer.d.ts +1 -1
- package/lib/chevre/service/task/confirmPayTransaction.d.ts +2 -2
- package/lib/chevre/service/task/confirmPayTransaction.js +3 -2
- package/lib/chevre/service/task/confirmRegisterService.d.ts +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmReserveTransaction.d.ts +6 -2
- package/lib/chevre/service/task/confirmReserveTransaction.js +3 -3
- package/lib/chevre/service/task/createAccountingReport.d.ts +1 -1
- package/lib/chevre/service/task/createEvent.d.ts +1 -1
- package/lib/chevre/service/task/deletePerson.d.ts +1 -1
- package/lib/chevre/service/task/deleteTransaction.d.ts +1 -1
- package/lib/chevre/service/task/givePointAward.d.ts +1 -1
- package/lib/chevre/service/task/givePointAward.js +1 -1
- package/lib/chevre/service/task/handleNotification.d.ts +4 -2
- package/lib/chevre/service/task/importEventCapacitiesFromCOA.d.ts +1 -1
- package/lib/chevre/service/task/importEventsFromCOA.d.ts +1 -1
- package/lib/chevre/service/task/importOffersFromCOA.d.ts +1 -1
- package/lib/chevre/service/task/invalidatePaymentUrl.d.ts +1 -1
- package/lib/chevre/service/task/moneyTransfer.d.ts +1 -1
- package/lib/chevre/service/task/moneyTransfer.js +1 -1
- package/lib/chevre/service/task/onAssetTransactionStatusChanged.d.ts +1 -1
- package/lib/chevre/service/task/onAuthorizationCreated.d.ts +1 -1
- package/lib/chevre/service/task/onEventChanged.d.ts +1 -1
- package/lib/chevre/service/task/onOrderPaymentCompleted.d.ts +1 -1
- package/lib/chevre/service/task/onResourceUpdated.d.ts +1 -1
- package/lib/chevre/service/task/pay.d.ts +1 -1
- package/lib/chevre/service/task/placeOrder.d.ts +1 -1
- package/lib/chevre/service/task/publishPaymentUrl.d.ts +1 -1
- package/lib/chevre/service/task/publishPaymentUrl.js +6 -7
- package/lib/chevre/service/task/refund.d.ts +1 -1
- package/lib/chevre/service/task/refund.js +1 -1
- package/lib/chevre/service/task/registerService.d.ts +1 -1
- package/lib/chevre/service/task/reserve.d.ts +1 -1
- package/lib/chevre/service/task/returnMoneyTransfer.d.ts +1 -1
- package/lib/chevre/service/task/returnMoneyTransfer.js +1 -1
- package/lib/chevre/service/task/returnOrder.d.ts +1 -1
- package/lib/chevre/service/task/returnPayTransaction.d.ts +1 -1
- package/lib/chevre/service/task/returnPayTransaction.js +1 -1
- package/lib/chevre/service/task/returnPointAward.d.ts +1 -1
- package/lib/chevre/service/task/returnPointAward.js +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.d.ts +1 -1
- package/lib/chevre/service/task/returnReserveTransaction.js +1 -1
- package/lib/chevre/service/task/sendEmailMessage.d.ts +1 -1
- package/lib/chevre/service/task/sendOrder.d.ts +1 -1
- package/lib/chevre/service/task/triggerWebhook.d.ts +1 -1
- package/lib/chevre/service/task/useReservation.d.ts +1 -1
- package/lib/chevre/service/task/voidMoneyTransferTransaction.d.ts +1 -1
- package/lib/chevre/service/task/voidPayTransaction.d.ts +1 -1
- package/lib/chevre/service/task/voidPayment.d.ts +1 -1
- package/lib/chevre/service/task/voidRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/voidReserveTransaction.d.ts +1 -1
- package/lib/chevre/service/task/voidReserveTransaction.js +5 -4
- package/lib/chevre/service/task.d.ts +7 -29
- package/lib/chevre/service/task.js +9 -114
- package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.d.ts +11 -0
- package/lib/chevre/service/taskHandler/onOperationFailed/informTaskIfNeeded.js +105 -0
- package/lib/chevre/service/taskHandler/onOperationFailed.d.ts +17 -0
- package/lib/chevre/service/taskHandler/onOperationFailed.js +70 -0
- package/lib/chevre/service/taskHandler.d.ts +26 -0
- package/lib/chevre/service/taskHandler.js +97 -0
- package/lib/chevre/service/validation/validateEvent.d.ts +2 -2
- package/lib/chevre/service/validation/validateEvent.js +16 -10
- package/lib/chevre/service/validation/validateOrder.js +55 -37
- package/lib/chevre/service.d.ts +0 -4
- package/lib/chevre/service.js +10 -14
- package/lib/chevre/settings/aggregation.d.ts +6 -1
- package/lib/chevre/settings/aggregation.js +2 -1
- package/package.json +6 -4
- package/example/src/chevre/adminAuth/adminIdentity.ts +0 -38
- package/example/src/chevre/executeOneTask.ts +0 -41
- package/example/src/chevre/executeTaskIfExists.ts +0 -80
- package/example/src/chevre/findExecutableTask.ts +0 -50
- package/example/src/chevre/findSetting.ts +0 -79
- package/example/src/chevre/roles/addRoleMembers.ts +0 -75
- package/example/src/chevre/searchPermissions.ts +0 -46
- package/example/src/chevre/searchProductOffers.ts +0 -29
- package/example/src/chevre/stockHolder/checkIfConflicted.ts +0 -76
- package/example/src/chevre/stockHolder/checkRedisKeyCount.ts +0 -195
- package/example/src/chevre/stockHolder/migratePendingReservations.ts +0 -96
- package/example/src/chevre/stockHolder/playAroundStockHolder.ts +0 -256
- package/example/src/chevre/transactionNumber/publishConfimationNumber.ts +0 -37
- package/example/src/chevre/transactionNumber/publishOrderNumber.ts +0 -40
- package/example/src/chevre/upsertProductsByProductId.ts +0 -100
- package/lib/chevre/adminAuth.d.ts +0 -2
- package/lib/chevre/adminAuth.js +0 -6
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console no-magic-numbers
|
|
2
|
+
import { ManagementClient } from 'auth0';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import * as moment from 'moment';
|
|
5
|
+
// import * as crypto from 'crypto'; // client_secret 生成用 (PKJWTなしの場合)
|
|
6
|
+
// import { JWK, importPKCS8, generateKeyPair, SignJWT } from 'jose'; // Private Key JWT 用
|
|
7
|
+
|
|
8
|
+
const PUBLIC_KEY_FILE_PATH = `${__dirname}/../../samplePublicKey.pem`;
|
|
9
|
+
const { AUTH0_DOMAIN, AUTH0_MGMT_CLIENT_ID, AUTH0_MGMT_CLIENT_SECRET, AUTH0_MGMT_API_AUDIENCE, AUTH0_AUDIENCE } = process.env;
|
|
10
|
+
|
|
11
|
+
if (typeof AUTH0_DOMAIN !== 'string'
|
|
12
|
+
|| typeof AUTH0_MGMT_CLIENT_ID !== 'string'
|
|
13
|
+
|| typeof AUTH0_MGMT_CLIENT_SECRET !== 'string'
|
|
14
|
+
|| typeof AUTH0_MGMT_API_AUDIENCE !== 'string'
|
|
15
|
+
|| typeof AUTH0_AUDIENCE !== 'string'
|
|
16
|
+
) {
|
|
17
|
+
throw new Error('set envs!');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// --- Auth0 ManagementClient の初期化 ---
|
|
21
|
+
const management = new ManagementClient({
|
|
22
|
+
domain: AUTH0_DOMAIN,
|
|
23
|
+
clientId: AUTH0_MGMT_CLIENT_ID,
|
|
24
|
+
clientSecret: AUTH0_MGMT_CLIENT_SECRET,
|
|
25
|
+
audience: AUTH0_MGMT_API_AUDIENCE
|
|
26
|
+
// scope: 'read:clients create:clients' // 必要なスコープを明示
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
async function sleep(waitInSeconds: number) {
|
|
30
|
+
await new Promise<void>((resolve) => {
|
|
31
|
+
setTimeout(
|
|
32
|
+
() => {
|
|
33
|
+
resolve();
|
|
34
|
+
},
|
|
35
|
+
waitInSeconds
|
|
36
|
+
);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* アプリケーションを検索し、存在しなければ作成します。
|
|
42
|
+
* Private Key JWT 認証を使用する前提。
|
|
43
|
+
*/
|
|
44
|
+
async function findOrCreateServiceAccount(
|
|
45
|
+
appName: string,
|
|
46
|
+
projectId: string,
|
|
47
|
+
roles: string[],
|
|
48
|
+
audience: string
|
|
49
|
+
) {
|
|
50
|
+
try {
|
|
51
|
+
console.log('getting organization...');
|
|
52
|
+
const getOrganizationResponse = await management.organizations.getByName({
|
|
53
|
+
name: projectId
|
|
54
|
+
});
|
|
55
|
+
const organization = getOrganizationResponse.data;
|
|
56
|
+
console.log('organization exists.', organization);
|
|
57
|
+
|
|
58
|
+
const newClient = (await management.clients.create({
|
|
59
|
+
name: appName,
|
|
60
|
+
app_type: 'non_interactive', // Machine to Machine アプリケーション
|
|
61
|
+
jwt_configuration: { // Private Key JWT の設定
|
|
62
|
+
alg: 'RS256' // 署名アルゴリズム
|
|
63
|
+
},
|
|
64
|
+
// token_endpoint_auth_method: 'client_secret_post',
|
|
65
|
+
client_authentication_methods: {
|
|
66
|
+
private_key_jwt: {
|
|
67
|
+
credentials: [{
|
|
68
|
+
alg: 'RS256',
|
|
69
|
+
/**
|
|
70
|
+
* Credential type. Supported types: public_key.
|
|
71
|
+
*
|
|
72
|
+
*/
|
|
73
|
+
credential_type: 'public_key',
|
|
74
|
+
// name?: string;
|
|
75
|
+
pem: readFileSync(PUBLIC_KEY_FILE_PATH, 'utf8')
|
|
76
|
+
|
|
77
|
+
}]
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
grant_types: ['client_credentials'],
|
|
81
|
+
organization_usage: 'require', // 組織での利用を許可
|
|
82
|
+
default_organization: {
|
|
83
|
+
organization_id: organization.id,
|
|
84
|
+
flows: ['client_credentials']
|
|
85
|
+
},
|
|
86
|
+
oidc_conformant: true,
|
|
87
|
+
client_metadata: {
|
|
88
|
+
roles: JSON.stringify(roles)
|
|
89
|
+
}
|
|
90
|
+
})).data;
|
|
91
|
+
console.log(`Successfully created new application: ${newClient.client_id} (${newClient.name})`);
|
|
92
|
+
|
|
93
|
+
console.log(`checking clientGrant... ${newClient.client_id} (${newClient.name})`);
|
|
94
|
+
await sleep(3000);
|
|
95
|
+
|
|
96
|
+
let clientGrant = (await management.clientGrants.getAll({
|
|
97
|
+
audience,
|
|
98
|
+
client_id: newClient.client_id
|
|
99
|
+
})).data.shift();
|
|
100
|
+
if (clientGrant === undefined) {
|
|
101
|
+
clientGrant = (await management.clientGrants.create({
|
|
102
|
+
client_id: newClient.client_id,
|
|
103
|
+
audience,
|
|
104
|
+
organization_usage: 'require',
|
|
105
|
+
allow_any_organization: false,
|
|
106
|
+
scope: ['iam.members.me.read']
|
|
107
|
+
})).data;
|
|
108
|
+
console.log(`clientGrant created. ${newClient.client_id} (${newClient.name})`);
|
|
109
|
+
} else {
|
|
110
|
+
console.log(`clientGrant already exists. ${newClient.client_id} (${newClient.name})`);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
console.log(`checking organizationClientGrant... ${newClient.client_id} (${newClient.name})`);
|
|
114
|
+
await sleep(3000);
|
|
115
|
+
const organizationClientGrant = (await management.organizations.getOrganizationClientGrants({
|
|
116
|
+
id: organization.id,
|
|
117
|
+
audience: 'https://development.apis.smart-theater.com',
|
|
118
|
+
client_id: newClient.client_id
|
|
119
|
+
})).data.shift();
|
|
120
|
+
if (organizationClientGrant === undefined) {
|
|
121
|
+
await management.organizations.postOrganizationClientGrants(
|
|
122
|
+
{
|
|
123
|
+
id: organization.id
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
grant_id: clientGrant.id
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
console.log(`organizationClientGrant created. ${newClient.client_id} (${newClient.name})`);
|
|
130
|
+
} else {
|
|
131
|
+
console.log(`organizationClientGrant already exists. ${newClient.client_id} (${newClient.name})`);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// 1. アプリケーションを検索 (名前で検索するのが一般的)
|
|
135
|
+
console.log('searching for applications...');
|
|
136
|
+
await sleep(3000);
|
|
137
|
+
|
|
138
|
+
await searchClients({ organization });
|
|
139
|
+
} catch (error) {
|
|
140
|
+
console.error(`Error finding or creating application: ${error.message}`);
|
|
141
|
+
throw error;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async function searchClients(params: {
|
|
146
|
+
organization: { id: string };
|
|
147
|
+
}) {
|
|
148
|
+
const existingApps = await management.clients.getAll({
|
|
149
|
+
include_totals: true,
|
|
150
|
+
// app_type: 'non_interactive',
|
|
151
|
+
// is_global: false,
|
|
152
|
+
// page: 0,
|
|
153
|
+
// per_page: 50,
|
|
154
|
+
// q: `name:"${appName}"`, // 名前で検索
|
|
155
|
+
q: `client_grant.organization_id:"${params.organization.id}"`,
|
|
156
|
+
// from: undefined,
|
|
157
|
+
take: 50
|
|
158
|
+
// is_client_credentials: true // Machine to Machine アプリケーションに絞る
|
|
159
|
+
});
|
|
160
|
+
const clients = existingApps.data.clients;
|
|
161
|
+
console.log(clients.length, 'existingApps exist.', clients);
|
|
162
|
+
console.log(clients.length, 'clients found.');
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export async function run() {
|
|
166
|
+
if (typeof AUTH0_AUDIENCE !== 'string') {
|
|
167
|
+
throw new Error('set envs!');
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
try {
|
|
171
|
+
await findOrCreateServiceAccount(
|
|
172
|
+
`sampleServiceAccount-${moment()
|
|
173
|
+
.format('YYYY-MM-DDTHH:mm:ss')}`,
|
|
174
|
+
'cinerino',
|
|
175
|
+
['inventoryManager', 'user'],
|
|
176
|
+
AUTH0_AUDIENCE
|
|
177
|
+
);
|
|
178
|
+
} catch (error) {
|
|
179
|
+
console.error('Failed to run provisioning script:', error);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
run();
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
interface IAuth0Config {
|
|
3
|
+
auth0Domain: string;
|
|
4
|
+
clientId: string;
|
|
5
|
+
clientSecret: string;
|
|
6
|
+
audience: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// 環境変数から機密情報を取得することを強く推奨します
|
|
10
|
+
const config: IAuth0Config = {
|
|
11
|
+
auth0Domain: String(process.env.AUTH0_DOMAIN),
|
|
12
|
+
clientId: String(process.env.AUTH0_CLIENT_ID),
|
|
13
|
+
clientSecret: String(process.env.AUTH0_CLIENT_SECRET),
|
|
14
|
+
audience: String(process.env.AUTH0_AUDIENCE)
|
|
15
|
+
// scopes: process.env.OKTA_SCOPES || 'api_access_scope openid', // 必要なスコープを指定
|
|
16
|
+
// authServerId: 'aussd9v86wlIar3cX697', // デフォルト承認サーバーを使用する場合はコメントアウトまたは指定しない
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
async function getToken() {
|
|
20
|
+
try {
|
|
21
|
+
const response = await fetch(
|
|
22
|
+
`https://${config.auth0Domain}/oauth/token`,
|
|
23
|
+
{
|
|
24
|
+
method: 'POST',
|
|
25
|
+
headers: { 'content-type': 'application/json' },
|
|
26
|
+
body: JSON.stringify({
|
|
27
|
+
client_id: config.clientId,
|
|
28
|
+
client_secret: config.clientSecret,
|
|
29
|
+
audience: config.audience,
|
|
30
|
+
grant_type: 'client_credentials'
|
|
31
|
+
// organization: 'org_zuMP9ng42QSgZ5Kn'
|
|
32
|
+
})
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
if (!response.ok) {
|
|
36
|
+
console.log(await response.json());
|
|
37
|
+
throw new Error('Network response was not ok');
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const data = await response.json();
|
|
41
|
+
console.log(data);
|
|
42
|
+
|
|
43
|
+
return data;
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error('Error fetching token:', error);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function main() {
|
|
50
|
+
const token = await getToken();
|
|
51
|
+
console.log(token);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
main()
|
|
55
|
+
.catch(console.error);
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
// tslint:disable:no-implicit-dependencies no-console
|
|
2
|
+
import * as crypto from 'crypto';
|
|
3
|
+
import { readFileSync } from 'fs';
|
|
4
|
+
import { SignJWT } from 'jose';
|
|
5
|
+
import * as uuid from 'uuid';
|
|
6
|
+
|
|
7
|
+
const PRIVATE_KEY_FILE_PATH = `${__dirname}/../../samplePrivateKey.pem`;
|
|
8
|
+
|
|
9
|
+
interface IAuth0Config {
|
|
10
|
+
auth0Domain: string;
|
|
11
|
+
clientId: string;
|
|
12
|
+
privateKeyContent: string; // PEM形式の秘密鍵の内容 (例: fs.readFileSync('private_key.pem', 'utf8'))
|
|
13
|
+
audience: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
// 環境変数から機密情報を取得することを強く推奨します
|
|
17
|
+
const auth0config: IAuth0Config = {
|
|
18
|
+
auth0Domain: String(process.env.AUTH0_DOMAIN),
|
|
19
|
+
clientId: String(process.env.AUTH0_CLIENT_ID),
|
|
20
|
+
// keyId: 'xxx',
|
|
21
|
+
privateKeyContent: readFileSync(PRIVATE_KEY_FILE_PATH, 'utf8'), // 秘密鍵の内容を読み込む
|
|
22
|
+
audience: String(process.env.AUTH0_AUDIENCE)
|
|
23
|
+
// scopes: process.env.OKTA_SCOPES || 'api_access_scope openid', // 必要なスコープを指定
|
|
24
|
+
// authServerId: 'aussd9v86wlIar3cX697', // デフォルト承認サーバーを使用する場合はコメントアウトまたは指定しない
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
async function generateJwtAssertion(config: IAuth0Config) {
|
|
28
|
+
const privateKeyPEM = crypto.createPrivateKey(readFileSync(PRIVATE_KEY_FILE_PATH, 'utf8'));
|
|
29
|
+
|
|
30
|
+
return new SignJWT({})
|
|
31
|
+
.setProtectedHeader({
|
|
32
|
+
alg: 'RS256' // or RS384 or PS256
|
|
33
|
+
// kid: '(OPTIONAL) KID_GENERATED_BY_AUTH0'
|
|
34
|
+
})
|
|
35
|
+
.setIssuedAt()
|
|
36
|
+
.setIssuer(config.clientId)
|
|
37
|
+
.setSubject(config.clientId)
|
|
38
|
+
.setAudience(`https://${config.auth0Domain}/`)
|
|
39
|
+
.setExpirationTime('1m')
|
|
40
|
+
.setJti(uuid.v4())
|
|
41
|
+
.sign(privateKeyPEM);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function getToken() {
|
|
45
|
+
try {
|
|
46
|
+
const jwtAssertion = await generateJwtAssertion(auth0config);
|
|
47
|
+
console.log('jwtAssertion:', jwtAssertion);
|
|
48
|
+
|
|
49
|
+
const body = new URLSearchParams({
|
|
50
|
+
grant_type: 'client_credentials',
|
|
51
|
+
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
|
|
52
|
+
client_assertion: jwtAssertion,
|
|
53
|
+
audience: auth0config.audience
|
|
54
|
+
// scope: config.scopes,
|
|
55
|
+
}).toString();
|
|
56
|
+
const response = await fetch(
|
|
57
|
+
`https://${auth0config.auth0Domain}/oauth/token`,
|
|
58
|
+
{
|
|
59
|
+
method: 'POST',
|
|
60
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
61
|
+
body: body
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
if (!response.ok) {
|
|
65
|
+
console.log(await response.json());
|
|
66
|
+
throw new Error('Network response was not ok');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const data = await response.json();
|
|
70
|
+
console.log(data);
|
|
71
|
+
|
|
72
|
+
return data;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error('Error fetching token:', error);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export async function main() {
|
|
79
|
+
const token = await getToken();
|
|
80
|
+
console.log(token);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
main()
|
|
84
|
+
.catch(console.error);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
const projectIdMustBe = /^[0-9a-z-]+$/; // 記号はhyphenのみ許可
|
|
3
|
+
|
|
4
|
+
let projectId: string;
|
|
5
|
+
|
|
6
|
+
projectId = 'projectId';
|
|
7
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
8
|
+
|
|
9
|
+
projectId = 'projectid';
|
|
10
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
11
|
+
|
|
12
|
+
projectId = 'abcd1234-test';
|
|
13
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
14
|
+
|
|
15
|
+
projectId = 'a-z';
|
|
16
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
17
|
+
|
|
18
|
+
projectId = '0-9';
|
|
19
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
20
|
+
|
|
21
|
+
projectId = '---';
|
|
22
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
23
|
+
|
|
24
|
+
projectId = '-';
|
|
25
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
26
|
+
|
|
27
|
+
projectId = '&';
|
|
28
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
29
|
+
|
|
30
|
+
projectId = 'A';
|
|
31
|
+
console.log(projectId, ':', projectIdMustBe.test(projectId));
|
|
@@ -12,30 +12,53 @@ interface IExecuteSettings {
|
|
|
12
12
|
*/
|
|
13
13
|
redisClient?: RedisClientType;
|
|
14
14
|
}
|
|
15
|
-
type IOperationExecute<T> = (settings: IExecuteSettings) => Promise<T>;
|
|
16
|
-
type INextFunction = (task: Pick<factory.task.ITask<factory.taskName>, 'id'>) => IOperationExecute<void>;
|
|
17
15
|
interface IReadyTask {
|
|
18
16
|
id: string;
|
|
19
17
|
name?: factory.taskName;
|
|
20
18
|
status: factory.taskStatus.Ready;
|
|
19
|
+
remainingNumberOfTries?: never;
|
|
21
20
|
expires?: Date;
|
|
22
21
|
executionResult?: never;
|
|
23
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* タスク名不明の遅延実行中タスク
|
|
25
|
+
*/
|
|
24
26
|
interface IRunningTask {
|
|
25
27
|
id: string;
|
|
26
28
|
status: factory.taskStatus.Running;
|
|
27
29
|
name?: never;
|
|
30
|
+
remainingNumberOfTries?: never;
|
|
31
|
+
expires?: never;
|
|
32
|
+
executionResult?: never;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* タスク名指定での遅延実行中タスク
|
|
36
|
+
*/
|
|
37
|
+
interface IRunningTaskByName {
|
|
38
|
+
id: string;
|
|
39
|
+
status: factory.taskStatus.Running;
|
|
40
|
+
name: factory.taskName;
|
|
41
|
+
remainingNumberOfTries?: never;
|
|
28
42
|
expires?: never;
|
|
29
43
|
executionResult?: never;
|
|
30
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* 実行後タスクイベント
|
|
47
|
+
*/
|
|
31
48
|
interface IExecutedTask {
|
|
32
49
|
id: string;
|
|
33
|
-
status: factory.taskStatus;
|
|
50
|
+
status: factory.taskStatus.Executed | factory.taskStatus.Running | factory.taskStatus.Aborted;
|
|
51
|
+
name: factory.taskName;
|
|
34
52
|
executionResult: factory.task.IExecutionResult;
|
|
35
|
-
|
|
53
|
+
/**
|
|
54
|
+
* 実行されたタスクの残り試行回数
|
|
55
|
+
*/
|
|
56
|
+
remainingNumberOfTries: number;
|
|
36
57
|
expires?: never;
|
|
37
58
|
}
|
|
38
|
-
type IChangedTask = IReadyTask | IRunningTask | IExecutedTask;
|
|
59
|
+
type IChangedTask = IReadyTask | IRunningTask | IRunningTaskByName | IExecutedTask;
|
|
60
|
+
type IOperationExecute<T> = (settings: IExecuteSettings) => Promise<T>;
|
|
61
|
+
type INextFunction = (task: IExecutedTask) => IOperationExecute<void>;
|
|
39
62
|
type IOnTaskStatusChangedListener = (task: IChangedTask, next?: INextFunction) => void;
|
|
40
63
|
/**
|
|
41
64
|
* タスクイベントエミッター
|
|
@@ -45,4 +68,4 @@ declare class TaskEventEmitter extends EventEmitter {
|
|
|
45
68
|
emitTaskStatusChanged(task: IChangedTask, next?: INextFunction): void;
|
|
46
69
|
}
|
|
47
70
|
declare const taskEventEmitter: TaskEventEmitter;
|
|
48
|
-
export { IChangedTask, IReadyTask, IRunningTask, IExecutedTask, IExecuteSettings, INextFunction, IOnTaskStatusChangedListener, taskEventEmitter };
|
|
71
|
+
export { IChangedTask, IReadyTask, IRunningTask, IRunningTaskByName, IExecutedTask, IExecuteSettings, INextFunction, IOnTaskStatusChangedListener, taskEventEmitter };
|
package/lib/chevre/index.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import type * as COAService from '@motionpicture/coa-service';
|
|
5
5
|
import type * as GMOService from '@motionpicture/gmo-service';
|
|
6
|
-
import type * as AdminAuth from './adminAuth';
|
|
7
6
|
import type * as Pecorinoapi from './pecorinoapi';
|
|
8
7
|
import { credentials } from './credentials';
|
|
9
8
|
import * as errorHandler from './errorHandler';
|
|
@@ -13,7 +12,6 @@ import * as repository from './repository';
|
|
|
13
12
|
import * as service from './service';
|
|
14
13
|
import * as settings from './settings';
|
|
15
14
|
export { credentials, errorHandler, eventEmitter, factory, repository, service, settings };
|
|
16
|
-
export declare function loadAdminAuth(): Promise<typeof AdminAuth>;
|
|
17
15
|
export declare function loadPecorinoapi(): Promise<typeof Pecorinoapi>;
|
|
18
16
|
export type COA = typeof COAService;
|
|
19
17
|
export declare function loadCOA(): Promise<typeof COAService>;
|
package/lib/chevre/index.js
CHANGED
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.settings = exports.service = exports.repository = exports.factory = exports.eventEmitter = exports.errorHandler = exports.credentials = void 0;
|
|
13
|
-
exports.loadAdminAuth = loadAdminAuth;
|
|
14
13
|
exports.loadPecorinoapi = loadPecorinoapi;
|
|
15
14
|
exports.loadCOA = loadCOA;
|
|
16
15
|
exports.loadGMO = loadGMO;
|
|
@@ -28,15 +27,6 @@ const service = require("./service");
|
|
|
28
27
|
exports.service = service;
|
|
29
28
|
const settings = require("./settings");
|
|
30
29
|
exports.settings = settings;
|
|
31
|
-
let adminAuth;
|
|
32
|
-
function loadAdminAuth() {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
if (adminAuth === undefined) {
|
|
35
|
-
adminAuth = yield Promise.resolve().then(() => require('./adminAuth'));
|
|
36
|
-
}
|
|
37
|
-
return adminAuth;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
30
|
let pecorinoapi;
|
|
41
31
|
function loadPecorinoapi() {
|
|
42
32
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import type { Connection } from 'mongoose';
|
|
2
|
-
import { RedisClientType } from 'redis';
|
|
3
2
|
/**
|
|
4
3
|
* 確認番号リポジトリ
|
|
5
4
|
*/
|
|
6
5
|
export declare class ConfirmationNumberRepo {
|
|
7
6
|
private readonly counterRepo;
|
|
8
7
|
constructor(params: {
|
|
9
|
-
redisClient: RedisClientType;
|
|
10
8
|
connection: Connection;
|
|
11
9
|
});
|
|
12
10
|
private static alignDigits;
|
|
@@ -18,5 +16,4 @@ export declare class ConfirmationNumberRepo {
|
|
|
18
16
|
publish(params: {
|
|
19
17
|
orderDate: Date;
|
|
20
18
|
}): Promise<string>;
|
|
21
|
-
private useMongoBySettings;
|
|
22
19
|
}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.ConfirmationNumberRepo = void 0;
|
|
13
13
|
const cdigit = require("cdigit");
|
|
14
14
|
const moment = require("moment-timezone");
|
|
15
|
+
// import { RedisClientType } from 'redis';
|
|
15
16
|
// tslint:disable-next-line:no-require-imports no-var-requires
|
|
16
17
|
const fpe = require('node-fpe');
|
|
17
18
|
// import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
|
|
@@ -72,55 +73,19 @@ class ConfirmationNumberRepo {
|
|
|
72
73
|
const dataFeedIdentifier = ConfirmationNumberRepo.createDataFeedIdentifier({ orderDate: params.orderDate });
|
|
73
74
|
let incrReply;
|
|
74
75
|
// support publishByMongo(2025-05-23~)
|
|
75
|
-
const useMongoBySettings =
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
// データ保管期間はとりあえず一か月
|
|
90
|
-
dataFeedExpires = moment(params.orderDate)
|
|
91
|
-
.add(1, 'month')
|
|
92
|
-
.toDate();
|
|
93
|
-
incrReply = yield this.counterRepo.incrementByRedis({
|
|
94
|
-
identifier: dataFeedIdentifier,
|
|
95
|
-
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
|
|
96
|
-
expires: dataFeedExpires
|
|
97
|
-
});
|
|
98
|
-
}
|
|
76
|
+
// const useMongoBySettings = await this.useMongoBySettings(params);
|
|
77
|
+
// データ保管期間はとりあえず2 months
|
|
78
|
+
dataFeedExpires = moment(params.orderDate)
|
|
79
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
80
|
+
.add(2, 'months')
|
|
81
|
+
.toDate();
|
|
82
|
+
incrReply = yield this.counterRepo.incrementByMongo({
|
|
83
|
+
identifier: dataFeedIdentifier,
|
|
84
|
+
includedInDataCatalog: { identifier: transactionNumber_1.DataCatalogIdentifier.confirmationNumber },
|
|
85
|
+
expires: dataFeedExpires
|
|
86
|
+
});
|
|
99
87
|
return ConfirmationNumberRepo.count2confirmationNumber({ count: incrReply });
|
|
100
88
|
});
|
|
101
89
|
}
|
|
102
|
-
// /**
|
|
103
|
-
// * DB移行時のみに使用目的の設定更新
|
|
104
|
-
// */
|
|
105
|
-
// public async setUseMongo4confirmationNumberFrom(params: {
|
|
106
|
-
// useMongo4confirmationNumberFrom: Date;
|
|
107
|
-
// }) {
|
|
108
|
-
// const { useMongo4confirmationNumberFrom } = params;
|
|
109
|
-
// return this.settingModel.findOneAndUpdate(
|
|
110
|
-
// { 'project.id': { $eq: '*' } },
|
|
111
|
-
// {
|
|
112
|
-
// $set: { useMongo4confirmationNumberFrom }
|
|
113
|
-
// },
|
|
114
|
-
// { projection: { _id: 0, useMongo4confirmationNumberFrom: 1 } }
|
|
115
|
-
// )
|
|
116
|
-
// .lean<Pick<ISetting, 'useMongo4confirmationNumberFrom'> | null>()
|
|
117
|
-
// .exec();
|
|
118
|
-
// }
|
|
119
|
-
// tslint:disable-next-line:prefer-function-over-method
|
|
120
|
-
useMongoBySettings(__) {
|
|
121
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
return true;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
90
|
}
|
|
126
91
|
exports.ConfirmationNumberRepo = ConfirmationNumberRepo;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Connection, FilterQuery, QueryOptions } from 'mongoose';
|
|
2
2
|
import * as factory from '../factory';
|
|
3
|
-
|
|
3
|
+
type ISavingSoftwareApplicationIdentity = Pick<factory.creativeWork.certification.softwareApplication.ICertification, 'about' | 'project' | 'typeOf'>;
|
|
4
|
+
type ISavingWebApplicationIdentity = Pick<factory.creativeWork.certification.webApplication.ICertification, 'about' | 'project' | 'typeOf'>;
|
|
5
|
+
export type ISavingIdentity = (ISavingSoftwareApplicationIdentity | ISavingWebApplicationIdentity) & {
|
|
4
6
|
id?: never;
|
|
5
7
|
dateCreated?: never;
|
|
6
8
|
dateModified?: never;
|
|
@@ -11,7 +13,7 @@ interface IUnset {
|
|
|
11
13
|
[key: string]: 1;
|
|
12
14
|
};
|
|
13
15
|
}
|
|
14
|
-
type IIdentityWithId = factory.creativeWork.certification.webApplication.ICertification & {
|
|
16
|
+
type IIdentityWithId = (factory.creativeWork.certification.softwareApplication.ICertification | factory.creativeWork.certification.webApplication.ICertification) & {
|
|
15
17
|
id: string;
|
|
16
18
|
};
|
|
17
19
|
type IKeyOfProjection = keyof factory.creativeWork.certification.webApplication.ICertification;
|
|
@@ -35,39 +37,15 @@ export declare class IdentityRepo {
|
|
|
35
37
|
id: string;
|
|
36
38
|
};
|
|
37
39
|
}): Promise<void>;
|
|
38
|
-
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, {
|
|
39
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
40
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
41
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
42
|
-
dateCreated?: Date | undefined;
|
|
43
|
-
dateModified?: Date | undefined;
|
|
44
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
45
|
-
}> & {
|
|
46
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
47
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
48
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
49
|
-
dateCreated?: Date | undefined;
|
|
50
|
-
dateModified?: Date | undefined;
|
|
51
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
52
|
-
} & {
|
|
40
|
+
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> | Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id">> & ((Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> & {
|
|
53
41
|
_id: import("mongoose").Types.ObjectId;
|
|
54
|
-
}
|
|
55
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
56
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
57
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
58
|
-
dateCreated?: Date | undefined;
|
|
59
|
-
dateModified?: Date | undefined;
|
|
60
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
61
|
-
}> & {
|
|
62
|
-
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
63
|
-
typeOf: factory.creativeWorkType.Certification;
|
|
64
|
-
about: import("@chevre/factory/lib/creativeWork/certification/webApplication").IAbout;
|
|
65
|
-
dateCreated?: Date | undefined;
|
|
66
|
-
dateModified?: Date | undefined;
|
|
67
|
-
issuedBy: import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy | import("@chevre/factory/lib/creativeWork/certification/webApplication").IIssuedBy[];
|
|
68
|
-
} & {
|
|
42
|
+
}) | (Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id"> & {
|
|
69
43
|
_id: import("mongoose").Types.ObjectId;
|
|
70
|
-
}
|
|
44
|
+
})), QueryOptions<import("mongoose").Document<unknown, {}, Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> | Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id">> & ((Omit<import("@chevre/factory/lib/creativeWork/certification/softwareApplication").ICertification, "id"> & {
|
|
45
|
+
_id: import("mongoose").Types.ObjectId;
|
|
46
|
+
}) | (Omit<import("@chevre/factory/lib/creativeWork/certification/webApplication").ICertification, "id"> & {
|
|
47
|
+
_id: import("mongoose").Types.ObjectId;
|
|
48
|
+
}))>>;
|
|
71
49
|
updateIssuedBy2array(params: Pick<ISavingIdentity, 'issuedBy'> & {
|
|
72
50
|
id: string;
|
|
73
51
|
}): Promise<void>;
|
|
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
12
|
-
var t = {};
|
|
13
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
14
|
-
t[p] = s[p];
|
|
15
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
16
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
17
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
18
|
-
t[p[i]] = s[p[i]];
|
|
19
|
-
}
|
|
20
|
-
return t;
|
|
21
|
-
};
|
|
22
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
12
|
exports.IdentityRepo = void 0;
|
|
24
13
|
const factory = require("../factory");
|
|
@@ -76,12 +65,15 @@ class IdentityRepo {
|
|
|
76
65
|
throw new factory.errors.ArgumentNull('id');
|
|
77
66
|
}
|
|
78
67
|
// issuedByのみ更新可能
|
|
79
|
-
const
|
|
68
|
+
const { project, $unset, issuedBy } = params.attributes;
|
|
80
69
|
const filter = {
|
|
81
70
|
_id: { $eq: savingId },
|
|
82
71
|
'project.id': { $eq: project.id }
|
|
83
72
|
};
|
|
84
|
-
const update = Object.assign({ $set:
|
|
73
|
+
const update = Object.assign({ $set: {
|
|
74
|
+
issuedBy,
|
|
75
|
+
dateModified: new Date()
|
|
76
|
+
} }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
|
|
85
77
|
const options = {
|
|
86
78
|
upsert: false,
|
|
87
79
|
new: true,
|
|
@@ -96,8 +88,11 @@ class IdentityRepo {
|
|
|
96
88
|
savedId = savingId;
|
|
97
89
|
}
|
|
98
90
|
else {
|
|
99
|
-
const
|
|
100
|
-
const result = yield this.identityModel.insertMany(
|
|
91
|
+
const { typeOf, about, project, issuedBy } = params.attributes;
|
|
92
|
+
const result = yield this.identityModel.insertMany({
|
|
93
|
+
typeOf, about, project, issuedBy,
|
|
94
|
+
dateCreated: new Date()
|
|
95
|
+
}, { rawResult: true });
|
|
101
96
|
const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
102
97
|
if (typeof insertedId !== 'string') {
|
|
103
98
|
throw new factory.errors.Internal(`seller not saved unexpectedly. result:${JSON.stringify(result)}`);
|