@chevre/domain 22.9.0-alpha.0 → 22.9.0-alpha.1
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/adminIdentityProviders.ts +65 -0
- package/lib/chevre/repo/application.js +1 -1
- package/lib/chevre/repo/identityProvider.d.ts +36 -0
- package/lib/chevre/repo/identityProvider.js +134 -0
- package/lib/chevre/repo/mongoose/schemas/identityProvider.d.ts +38 -0
- package/lib/chevre/repo/mongoose/schemas/identityProvider.js +76 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/package.json +1 -1
- package/example/src/chevre/adminApplications.ts +0 -66
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
const IDENTIFIER = 'https://example.com';
|
|
8
|
+
|
|
9
|
+
async function main() {
|
|
10
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
+
|
|
12
|
+
const providerRepo = await chevre.repository.IdentityProvider.createInstance(mongoose.connection);
|
|
13
|
+
|
|
14
|
+
let providers = await providerRepo.projectFields(
|
|
15
|
+
{
|
|
16
|
+
project: { id: { $eq: project.id } },
|
|
17
|
+
identifier: { $eq: IDENTIFIER }
|
|
18
|
+
},
|
|
19
|
+
['identifier', 'typeOf', 'verified', 'project']
|
|
20
|
+
);
|
|
21
|
+
console.log('providers:', providers);
|
|
22
|
+
console.log(providers.length, 'providers found');
|
|
23
|
+
|
|
24
|
+
if (providers.length > 0) {
|
|
25
|
+
await providerRepo.deleteById({
|
|
26
|
+
project: { id: providers[0].project.id },
|
|
27
|
+
id: providers[0].id
|
|
28
|
+
});
|
|
29
|
+
console.log('application deleted', providers[0].id);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await providerRepo.projectFields(
|
|
33
|
+
{
|
|
34
|
+
project: { id: { $eq: project.id } },
|
|
35
|
+
identifier: { $eq: IDENTIFIER }
|
|
36
|
+
},
|
|
37
|
+
['identifier', 'typeOf', 'verified', 'project']
|
|
38
|
+
);
|
|
39
|
+
console.log('providers:', providers);
|
|
40
|
+
console.log(providers.length, 'providers found');
|
|
41
|
+
|
|
42
|
+
await providerRepo.save({
|
|
43
|
+
attributes: {
|
|
44
|
+
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
45
|
+
typeOf: chevre.factory.organizationType.Organization,
|
|
46
|
+
identifier: IDENTIFIER,
|
|
47
|
+
verified: false
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
console.log('application created');
|
|
51
|
+
|
|
52
|
+
providers = await await providerRepo.projectFields(
|
|
53
|
+
{
|
|
54
|
+
project: { id: { $eq: project.id } },
|
|
55
|
+
identifier: { $eq: IDENTIFIER }
|
|
56
|
+
},
|
|
57
|
+
['identifier', 'typeOf', 'verified', 'project']
|
|
58
|
+
);
|
|
59
|
+
console.log('providers:', providers);
|
|
60
|
+
console.log(providers.length, 'providers found');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
main()
|
|
64
|
+
.then()
|
|
65
|
+
.catch(console.error);
|
|
@@ -118,7 +118,7 @@ class ApplicationRepo {
|
|
|
118
118
|
.skip(conditions.limit * (page - 1));
|
|
119
119
|
}
|
|
120
120
|
if (typeof ((_a = conditions.sort) === null || _a === void 0 ? void 0 : _a.clientId) === 'number') {
|
|
121
|
-
query.sort({
|
|
121
|
+
query.sort({ clientId: conditions.sort.clientId });
|
|
122
122
|
}
|
|
123
123
|
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
124
124
|
.lean()
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Connection, FilterQuery } from 'mongoose';
|
|
2
|
+
import { IIdentityProvider, ISearchConditions } from './mongoose/schemas/identityProvider';
|
|
3
|
+
export type ISavingIdentityProvider = Pick<IIdentityProvider, 'identifier' | 'project' | 'typeOf' | 'verified'> & {
|
|
4
|
+
id?: never;
|
|
5
|
+
};
|
|
6
|
+
interface IUnset {
|
|
7
|
+
$unset?: {
|
|
8
|
+
[key: string]: 1;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
type IIdentityProviderWithId = IIdentityProvider & {
|
|
12
|
+
id: string;
|
|
13
|
+
};
|
|
14
|
+
type IKeyOfProjection = keyof IIdentityProvider;
|
|
15
|
+
/**
|
|
16
|
+
* IDPリポジトリ
|
|
17
|
+
*/
|
|
18
|
+
export declare class IdentityProviderRepo {
|
|
19
|
+
private readonly identityProviderModel;
|
|
20
|
+
constructor(connection: Connection);
|
|
21
|
+
static CREATE_FILTER_QUERY(params: ISearchConditions): FilterQuery<IIdentityProvider>[];
|
|
22
|
+
save(params: {
|
|
23
|
+
id?: string;
|
|
24
|
+
attributes: ISavingIdentityProvider & IUnset;
|
|
25
|
+
}): Promise<{
|
|
26
|
+
id: string;
|
|
27
|
+
}>;
|
|
28
|
+
projectFields(conditions: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IIdentityProviderWithId[]>;
|
|
29
|
+
deleteById(params: {
|
|
30
|
+
id: string;
|
|
31
|
+
project: {
|
|
32
|
+
id: string;
|
|
33
|
+
};
|
|
34
|
+
}): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,134 @@
|
|
|
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
|
+
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.IdentityProviderRepo = void 0;
|
|
24
|
+
const factory = require("../factory");
|
|
25
|
+
const settings_1 = require("../settings");
|
|
26
|
+
const identityProvider_1 = require("./mongoose/schemas/identityProvider");
|
|
27
|
+
/**
|
|
28
|
+
* IDPリポジトリ
|
|
29
|
+
*/
|
|
30
|
+
class IdentityProviderRepo {
|
|
31
|
+
constructor(connection) {
|
|
32
|
+
this.identityProviderModel = connection.model(identityProvider_1.modelName, (0, identityProvider_1.createSchema)());
|
|
33
|
+
}
|
|
34
|
+
// tslint:disable-next-line:max-func-body-length
|
|
35
|
+
static CREATE_FILTER_QUERY(params) {
|
|
36
|
+
var _a, _b, _c, _d, _e, _f;
|
|
37
|
+
const andConditions = [];
|
|
38
|
+
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
39
|
+
if (typeof projectIdEq === 'string') {
|
|
40
|
+
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
41
|
+
}
|
|
42
|
+
const idEq = (_c = params.id) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
43
|
+
if (typeof idEq === 'string') {
|
|
44
|
+
andConditions.push({ _id: { $eq: idEq } });
|
|
45
|
+
}
|
|
46
|
+
const idIn = (_d = params.id) === null || _d === void 0 ? void 0 : _d.$in;
|
|
47
|
+
if (Array.isArray(idIn)) {
|
|
48
|
+
andConditions.push({ _id: { $in: idIn } });
|
|
49
|
+
}
|
|
50
|
+
const identifierEq = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
51
|
+
if (typeof identifierEq === 'string') {
|
|
52
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
53
|
+
}
|
|
54
|
+
const identifierRegex = (_f = params.identifier) === null || _f === void 0 ? void 0 : _f.$regex;
|
|
55
|
+
if (typeof identifierRegex === 'string' && identifierRegex.length > 0) {
|
|
56
|
+
andConditions.push({ identifier: { $regex: new RegExp(identifierRegex) } });
|
|
57
|
+
}
|
|
58
|
+
const verified = params.verified;
|
|
59
|
+
if (typeof verified === 'boolean') {
|
|
60
|
+
andConditions.push({ verified: verified });
|
|
61
|
+
}
|
|
62
|
+
return andConditions;
|
|
63
|
+
}
|
|
64
|
+
save(params) {
|
|
65
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
var _a, _b;
|
|
67
|
+
let doc;
|
|
68
|
+
let savedId;
|
|
69
|
+
const savingId = params.id;
|
|
70
|
+
if (typeof savingId === 'string') {
|
|
71
|
+
if (savingId === '') {
|
|
72
|
+
throw new factory.errors.ArgumentNull('id');
|
|
73
|
+
}
|
|
74
|
+
const _c = params.attributes, { id, identifier, project, typeOf, $unset } = _c, updateFields = __rest(_c, ["id", "identifier", "project", "typeOf", "$unset"]);
|
|
75
|
+
const filter = {
|
|
76
|
+
_id: { $eq: savingId },
|
|
77
|
+
'project.id': { $eq: project.id }
|
|
78
|
+
};
|
|
79
|
+
const update = Object.assign({ $set: updateFields }, ($unset !== undefined && $unset !== null) ? { $unset } : undefined);
|
|
80
|
+
const options = {
|
|
81
|
+
upsert: false,
|
|
82
|
+
new: true,
|
|
83
|
+
projection: { _id: 1, id: { $toString: '$_id' } }
|
|
84
|
+
};
|
|
85
|
+
doc = yield this.identityProviderModel.findOneAndUpdate(filter, update, options)
|
|
86
|
+
.lean()
|
|
87
|
+
.exec();
|
|
88
|
+
if (doc === null) {
|
|
89
|
+
throw new factory.errors.NotFound(this.identityProviderModel.modelName);
|
|
90
|
+
}
|
|
91
|
+
savedId = savingId;
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
const _d = params.attributes, { $unset, id } = _d, createParams = __rest(_d, ["$unset", "id"]);
|
|
95
|
+
const result = yield this.identityProviderModel.insertMany(createParams, { rawResult: true });
|
|
96
|
+
const insertedId = (_b = (_a = result.insertedIds) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.toHexString();
|
|
97
|
+
if (typeof insertedId !== 'string') {
|
|
98
|
+
throw new factory.errors.Internal(`not saved unexpectedly. result:${JSON.stringify(result)}`);
|
|
99
|
+
}
|
|
100
|
+
savedId = insertedId;
|
|
101
|
+
}
|
|
102
|
+
return { id: savedId };
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
projectFields(conditions, inclusion) {
|
|
106
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
107
|
+
var _a;
|
|
108
|
+
const andConditions = IdentityProviderRepo.CREATE_FILTER_QUERY(conditions);
|
|
109
|
+
const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(inclusion.map((key) => ([key, 1]))));
|
|
110
|
+
const query = this.identityProviderModel.find((andConditions.length > 0) ? { $and: andConditions } : {}, projection);
|
|
111
|
+
if (typeof conditions.limit === 'number' && conditions.limit > 0) {
|
|
112
|
+
const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
|
|
113
|
+
query.limit(conditions.limit)
|
|
114
|
+
.skip(conditions.limit * (page - 1));
|
|
115
|
+
}
|
|
116
|
+
if (typeof ((_a = conditions.sort) === null || _a === void 0 ? void 0 : _a.identifier) === 'number') {
|
|
117
|
+
query.sort({ identifier: conditions.sort.identifier });
|
|
118
|
+
}
|
|
119
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
120
|
+
.lean()
|
|
121
|
+
.exec();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
deleteById(params) {
|
|
125
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
126
|
+
yield this.identityProviderModel.findOneAndDelete({
|
|
127
|
+
_id: { $eq: params.id },
|
|
128
|
+
'project.id': { $eq: params.project.id }
|
|
129
|
+
}, { projection: { _id: 1 } })
|
|
130
|
+
.exec();
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.IdentityProviderRepo = IdentityProviderRepo;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
export interface ISearchConditions {
|
|
4
|
+
limit?: number;
|
|
5
|
+
page?: number;
|
|
6
|
+
sort?: {
|
|
7
|
+
identifier?: factory.sortType;
|
|
8
|
+
};
|
|
9
|
+
project?: {
|
|
10
|
+
id?: {
|
|
11
|
+
$eq?: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
id?: {
|
|
15
|
+
$eq?: string;
|
|
16
|
+
$in?: string[];
|
|
17
|
+
};
|
|
18
|
+
identifier?: {
|
|
19
|
+
$eq?: string;
|
|
20
|
+
$regex?: string;
|
|
21
|
+
};
|
|
22
|
+
verified?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface IIdentityProvider {
|
|
25
|
+
id: string;
|
|
26
|
+
identifier: string;
|
|
27
|
+
project: Pick<factory.project.IProject, 'id' | 'typeOf'>;
|
|
28
|
+
typeOf: factory.organizationType.Organization;
|
|
29
|
+
verified: boolean;
|
|
30
|
+
}
|
|
31
|
+
type IDocType = Omit<IIdentityProvider, 'id'>;
|
|
32
|
+
type IModel = Model<IDocType>;
|
|
33
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
34
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
35
|
+
declare const modelName = "IdentityProvider";
|
|
36
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
37
|
+
declare function createSchema(): ISchema;
|
|
38
|
+
export { createSchema, IModel, indexes, modelName };
|
|
@@ -0,0 +1,76 @@
|
|
|
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 = 'IdentityProvider';
|
|
9
|
+
exports.modelName = modelName;
|
|
10
|
+
const schemaDefinition = {
|
|
11
|
+
project: {
|
|
12
|
+
type: mongoose_1.SchemaTypes.Mixed,
|
|
13
|
+
required: true
|
|
14
|
+
},
|
|
15
|
+
typeOf: {
|
|
16
|
+
type: String,
|
|
17
|
+
required: true
|
|
18
|
+
},
|
|
19
|
+
identifier: {
|
|
20
|
+
type: String,
|
|
21
|
+
required: true
|
|
22
|
+
},
|
|
23
|
+
verified: {
|
|
24
|
+
type: Boolean,
|
|
25
|
+
required: true
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const schemaOptions = {
|
|
29
|
+
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
30
|
+
autoCreate: false,
|
|
31
|
+
collection: 'identityProviders',
|
|
32
|
+
id: true,
|
|
33
|
+
read: settings_1.MONGO_READ_PREFERENCE,
|
|
34
|
+
writeConcern: writeConcern_1.writeConcern,
|
|
35
|
+
strict: true,
|
|
36
|
+
strictQuery: false,
|
|
37
|
+
timestamps: false,
|
|
38
|
+
versionKey: false,
|
|
39
|
+
toJSON: {
|
|
40
|
+
getters: false,
|
|
41
|
+
virtuals: false,
|
|
42
|
+
minimize: false,
|
|
43
|
+
versionKey: false
|
|
44
|
+
},
|
|
45
|
+
toObject: {
|
|
46
|
+
getters: false,
|
|
47
|
+
virtuals: true,
|
|
48
|
+
minimize: false,
|
|
49
|
+
versionKey: false
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const indexes = [
|
|
53
|
+
[
|
|
54
|
+
{ 'project.id': 1, identifier: 1 },
|
|
55
|
+
{
|
|
56
|
+
name: 'uniqueIdentifier',
|
|
57
|
+
unique: true
|
|
58
|
+
}
|
|
59
|
+
]
|
|
60
|
+
];
|
|
61
|
+
exports.indexes = indexes;
|
|
62
|
+
/**
|
|
63
|
+
* IDPスキーマ
|
|
64
|
+
*/
|
|
65
|
+
let schema;
|
|
66
|
+
function createSchema() {
|
|
67
|
+
if (schema === undefined) {
|
|
68
|
+
schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
|
|
69
|
+
if (settings_1.MONGO_AUTO_INDEX) {
|
|
70
|
+
indexes.forEach((indexParams) => {
|
|
71
|
+
schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return schema;
|
|
76
|
+
}
|
|
@@ -24,6 +24,7 @@ import type { EmailMessageRepo } from './repo/emailMessage';
|
|
|
24
24
|
import type { EventRepo } from './repo/event';
|
|
25
25
|
import type { EventSellerMakesOfferRepo } from './repo/eventSellerMakesOffer';
|
|
26
26
|
import type { EventSeriesRepo } from './repo/eventSeries';
|
|
27
|
+
import type { IdentityProviderRepo } from './repo/identityProvider';
|
|
27
28
|
import type { InterfaceRepo } from './repo/interface';
|
|
28
29
|
import type { IssuerRepo } from './repo/issuer';
|
|
29
30
|
import type { MemberRepo } from './repo/member';
|
|
@@ -173,6 +174,10 @@ export type EventSeries = EventSeriesRepo;
|
|
|
173
174
|
export declare namespace EventSeries {
|
|
174
175
|
function createInstance(...params: ConstructorParameters<typeof EventSeriesRepo>): Promise<EventSeriesRepo>;
|
|
175
176
|
}
|
|
177
|
+
export type IdentityProvider = IdentityProviderRepo;
|
|
178
|
+
export declare namespace IdentityProvider {
|
|
179
|
+
function createInstance(...params: ConstructorParameters<typeof IdentityProviderRepo>): Promise<IdentityProviderRepo>;
|
|
180
|
+
}
|
|
176
181
|
export type Interface = InterfaceRepo;
|
|
177
182
|
export declare namespace Interface {
|
|
178
183
|
function createInstance(...params: ConstructorParameters<typeof InterfaceRepo>): Promise<InterfaceRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -9,8 +9,8 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
13
|
-
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.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.Seller = exports.Schedule = exports.Role = exports.Reservation = exports.ProjectMakesOffer = exports.Project = void 0;
|
|
12
|
+
exports.ProductModel = exports.Product = exports.PriceSpecification = exports.place = exports.Permit = exports.Person = exports.paymentMethod = exports.PaymentServiceProvider = exports.PaymentService = exports.Passport = exports.OwnershipInfo = exports.OrderNumber = exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.Note = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.Interface = exports.IdentityProvider = 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.Application = exports.Aggregation = exports.AggregateReservation = exports.AggregateOffer = exports.AdditionalProperty = exports.Action = exports.AccountTransaction = exports.AccountTitle = exports.AccountingReport = exports.Account = exports.AcceptedOffer = void 0;
|
|
13
|
+
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.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.Seller = exports.Schedule = exports.Role = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductOffer = void 0;
|
|
14
14
|
var AcceptedOffer;
|
|
15
15
|
(function (AcceptedOffer) {
|
|
16
16
|
let repo;
|
|
@@ -323,6 +323,19 @@ var EventSeries;
|
|
|
323
323
|
}
|
|
324
324
|
EventSeries.createInstance = createInstance;
|
|
325
325
|
})(EventSeries || (exports.EventSeries = EventSeries = {}));
|
|
326
|
+
var IdentityProvider;
|
|
327
|
+
(function (IdentityProvider) {
|
|
328
|
+
let repo;
|
|
329
|
+
function createInstance(...params) {
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
if (repo === undefined) {
|
|
332
|
+
repo = (yield Promise.resolve().then(() => require('./repo/identityProvider'))).IdentityProviderRepo;
|
|
333
|
+
}
|
|
334
|
+
return new repo(...params);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
IdentityProvider.createInstance = createInstance;
|
|
338
|
+
})(IdentityProvider || (exports.IdentityProvider = IdentityProvider = {}));
|
|
326
339
|
var Interface;
|
|
327
340
|
(function (Interface) {
|
|
328
341
|
let repo;
|
package/package.json
CHANGED
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
const IDENTIFIER = '12345abcde';
|
|
8
|
-
|
|
9
|
-
async function main() {
|
|
10
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
11
|
-
|
|
12
|
-
const applicationRepo = await chevre.repository.Application.createInstance(mongoose.connection);
|
|
13
|
-
|
|
14
|
-
let applications = await applicationRepo.projectFields(
|
|
15
|
-
{
|
|
16
|
-
project: { id: { $eq: project.id } },
|
|
17
|
-
clientId: { $eq: IDENTIFIER }
|
|
18
|
-
},
|
|
19
|
-
['clientId', 'issuer', 'typeOf', 'verified', 'project']
|
|
20
|
-
);
|
|
21
|
-
console.log('applications:', applications);
|
|
22
|
-
console.log(applications.length, 'applications found');
|
|
23
|
-
|
|
24
|
-
if (applications.length > 0) {
|
|
25
|
-
await applicationRepo.deleteById({
|
|
26
|
-
project: { id: applications[0].project.id },
|
|
27
|
-
id: applications[0].id
|
|
28
|
-
});
|
|
29
|
-
console.log('application deleted', applications[0].id);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
await applicationRepo.projectFields(
|
|
33
|
-
{
|
|
34
|
-
project: { id: { $eq: project.id } },
|
|
35
|
-
clientId: { $eq: IDENTIFIER }
|
|
36
|
-
},
|
|
37
|
-
['clientId', 'issuer', 'typeOf', 'verified', 'project']
|
|
38
|
-
);
|
|
39
|
-
console.log('applications:', applications);
|
|
40
|
-
console.log(applications.length, 'applications found');
|
|
41
|
-
|
|
42
|
-
await applicationRepo.save({
|
|
43
|
-
attributes: {
|
|
44
|
-
project: { id: project.id, typeOf: chevre.factory.organizationType.Project },
|
|
45
|
-
typeOf: chevre.factory.creativeWorkType.WebApplication,
|
|
46
|
-
clientId: IDENTIFIER,
|
|
47
|
-
issuer: 'https://example.com',
|
|
48
|
-
verified: false
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
console.log('application created');
|
|
52
|
-
|
|
53
|
-
applications = await await applicationRepo.projectFields(
|
|
54
|
-
{
|
|
55
|
-
project: { id: { $eq: project.id } },
|
|
56
|
-
clientId: { $eq: IDENTIFIER }
|
|
57
|
-
},
|
|
58
|
-
['clientId', 'issuer', 'typeOf', 'verified', 'project']
|
|
59
|
-
);
|
|
60
|
-
console.log('applications:', applications);
|
|
61
|
-
console.log(applications.length, 'applications found');
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
main()
|
|
65
|
-
.then()
|
|
66
|
-
.catch(console.error);
|