@diia-inhouse/test 7.3.23 → 8.0.0
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/dist/dbUtilsBuilder.d.ts +29 -0
- package/dist/dbUtilsBuilder.js +81 -114
- package/dist/documentsGenerator.d.ts +8 -0
- package/dist/documentsGenerator.js +14 -21
- package/dist/index.d.ts +16 -0
- package/dist/index.js +19 -27
- package/dist/interfaces/index.d.ts +6 -0
- package/dist/publicServiceGenerator.d.ts +9 -0
- package/dist/publicServiceGenerator.js +25 -23
- package/dist/randomGenerator.d.ts +7 -0
- package/dist/randomGenerator.js +14 -18
- package/dist/sessionGenerator.d.ts +37 -0
- package/dist/sessionGenerator.js +340 -335
- package/dist/stubs/documents/index.js +13 -16
- package/package.json +28 -31
- package/vitest/extend-expect.ts +1 -2
- package/vitest/matchers/toBeDesignSystemElement/index.ts +1 -1
- package/vitest/tsconfig.json +1 -0
- package/dist/dbUtilsBuilder.js.map +0 -1
- package/dist/documentsGenerator.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/interfaces/documents/driverLicense.js +0 -63
- package/dist/interfaces/documents/driverLicense.js.map +0 -1
- package/dist/interfaces/documents/foreignPassport.js +0 -20
- package/dist/interfaces/documents/foreignPassport.js.map +0 -1
- package/dist/interfaces/documents/index.js +0 -40
- package/dist/interfaces/documents/index.js.map +0 -1
- package/dist/interfaces/documents/internalPassport.js +0 -19
- package/dist/interfaces/documents/internalPassport.js.map +0 -1
- package/dist/interfaces/documents/taxpayerCard.js +0 -3
- package/dist/interfaces/documents/taxpayerCard.js.map +0 -1
- package/dist/interfaces/index.js +0 -3
- package/dist/interfaces/index.js.map +0 -1
- package/dist/publicServiceGenerator.js.map +0 -1
- package/dist/randomGenerator.js.map +0 -1
- package/dist/sessionGenerator.js.map +0 -1
- package/dist/stubs/documents/driverLicense.js +0 -233
- package/dist/stubs/documents/driverLicense.js.map +0 -1
- package/dist/stubs/documents/foreignPassport.js +0 -63
- package/dist/stubs/documents/foreignPassport.js.map +0 -1
- package/dist/stubs/documents/index.js.map +0 -1
- package/dist/stubs/documents/internalPassport.js +0 -59
- package/dist/stubs/documents/internalPassport.js.map +0 -1
- package/dist/stubs/documents/taxpayerCard.js +0 -20
- package/dist/stubs/documents/taxpayerCard.js.map +0 -1
- package/dist/stubs/photo.js +0 -5
- package/dist/stubs/photo.js.map +0 -1
- package/dist/stubs/signature.js +0 -5
- package/dist/stubs/signature.js.map +0 -1
- package/dist/types/dbUtilsBuilder.d.ts +0 -29
- package/dist/types/documentsGenerator.d.ts +0 -4
- package/dist/types/index.d.ts +0 -13
- package/dist/types/interfaces/documents/driverLicense.d.ts +0 -120
- package/dist/types/interfaces/documents/foreignPassport.d.ts +0 -87
- package/dist/types/interfaces/documents/index.d.ts +0 -82
- package/dist/types/interfaces/documents/internalPassport.d.ts +0 -49
- package/dist/types/interfaces/documents/taxpayerCard.d.ts +0 -17
- package/dist/types/interfaces/index.d.ts +0 -7
- package/dist/types/publicServiceGenerator.d.ts +0 -5
- package/dist/types/randomGenerator.d.ts +0 -4
- package/dist/types/sessionGenerator.d.ts +0 -33
- package/dist/types/stubs/documents/driverLicense.d.ts +0 -3
- package/dist/types/stubs/documents/foreignPassport.d.ts +0 -3
- package/dist/types/stubs/documents/index.d.ts +0 -2
- package/dist/types/stubs/documents/internalPassport.d.ts +0 -3
- package/dist/types/stubs/documents/taxpayerCard.d.ts +0 -3
- package/dist/types/stubs/photo.d.ts +0 -2
- package/dist/types/stubs/signature.d.ts +0 -2
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { NodePgDatabase } from "drizzle-orm/node-postgres";
|
|
2
|
+
|
|
3
|
+
//#region src/dbUtilsBuilder.d.ts
|
|
4
|
+
type DatabaseAdapterType = "mongo" | "postgres";
|
|
5
|
+
type DbUtils<TFactory extends Record<string, (data?: any) => any>, TEntitySchema extends { [K in keyof TFactory]: ReturnType<TFactory[K]> }, TEntityName extends keyof TEntitySchema & keyof TFactory & string, TDbReference extends Partial<Record<TEntityName, Partial<Record<DatabaseAdapterType, any>>>>, TSavableEntity extends keyof TDbReference> = { [K in TEntityName]: {
|
|
6
|
+
seed: {
|
|
7
|
+
make: (data?: Partial<TEntitySchema[K]>) => TEntitySchema[K];
|
|
8
|
+
many: (count: number) => {
|
|
9
|
+
make: (data?: Partial<TEntitySchema[K]>) => TEntitySchema[K][];
|
|
10
|
+
} & (K extends TSavableEntity ? {
|
|
11
|
+
save: (data?: Partial<TEntitySchema[K]>) => Promise<TEntitySchema[K][]>;
|
|
12
|
+
} : {});
|
|
13
|
+
} & (K extends TSavableEntity ? {
|
|
14
|
+
save: (data?: Partial<TEntitySchema[K]>) => Promise<TEntitySchema[K]>;
|
|
15
|
+
} : {});
|
|
16
|
+
} & (K extends TSavableEntity ? {
|
|
17
|
+
cleanupBy: <P extends keyof TEntitySchema[K]>(by: P, values: TEntitySchema[K][P][]) => Promise<TEntitySchema[K][]>;
|
|
18
|
+
updateBy: <P extends keyof TEntitySchema[K]>(by: P, values: TEntitySchema[K][P][], data: Partial<TEntitySchema[K]>) => Promise<TEntitySchema[K][]>;
|
|
19
|
+
} : {}) };
|
|
20
|
+
type DbUtilsParams = {
|
|
21
|
+
databaseAdapter: DatabaseAdapterType;
|
|
22
|
+
db?: NodePgDatabase<Record<string, unknown>>;
|
|
23
|
+
};
|
|
24
|
+
declare function buildDbUtilsFn<TFactory extends Record<string, (data?: any) => any>, TEntitySchema extends { [K in keyof TFactory]: ReturnType<TFactory[K]> }, TEntityName extends keyof TEntitySchema & keyof TFactory & string, TDbReference extends Partial<Record<TEntityName, Partial<Record<DatabaseAdapterType, any>>>>, TSavableEntity extends keyof TDbReference>(factories: TFactory, references: TDbReference): ({
|
|
25
|
+
databaseAdapter,
|
|
26
|
+
db
|
|
27
|
+
}: DbUtilsParams) => DbUtils<TFactory, TEntitySchema, TEntityName, TDbReference, TSavableEntity>;
|
|
28
|
+
//#endregion
|
|
29
|
+
export { buildDbUtilsFn };
|
package/dist/dbUtilsBuilder.js
CHANGED
|
@@ -1,116 +1,83 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.buildDbUtilsFn = buildDbUtilsFn;
|
|
4
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
5
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
6
|
-
const drizzle_orm_1 = require("drizzle-orm");
|
|
1
|
+
import { inArray } from "drizzle-orm";
|
|
2
|
+
//#region src/dbUtilsBuilder.ts
|
|
7
3
|
function buildDbUtilsFn(factories, references) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
return deleted;
|
|
86
|
-
}
|
|
87
|
-
async function updateBy(entity, by, values, data) {
|
|
88
|
-
if (databaseAdapter === 'postgres') {
|
|
89
|
-
if (!db) {
|
|
90
|
-
throw new Error('Postgres database is not provided');
|
|
91
|
-
}
|
|
92
|
-
const pgTable = references[entity]?.postgres;
|
|
93
|
-
if (!pgTable) {
|
|
94
|
-
throw new Error(`No postgres reference for ${entity}`);
|
|
95
|
-
}
|
|
96
|
-
const column = pgTable[by];
|
|
97
|
-
const result = await db.update(pgTable).set(data).where((0, drizzle_orm_1.inArray)(column, values)).returning();
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
const model = references[entity]?.mongo;
|
|
101
|
-
if (!model?.updateMany || !model?.find) {
|
|
102
|
-
throw new Error(`No mongo reference for ${entity}`);
|
|
103
|
-
}
|
|
104
|
-
await model.updateMany({ [by === 'id' ? '_id' : by]: { $in: values } }, { $set: data });
|
|
105
|
-
return await model.find({ [by === 'id' ? '_id' : by]: { $in: values } });
|
|
106
|
-
}
|
|
107
|
-
return new Proxy({}, {
|
|
108
|
-
get: (_, entity) => ({
|
|
109
|
-
seed: { ...seedOne(entity), many: (count) => seedMany(count, entity) },
|
|
110
|
-
cleanupBy: (by, values) => cleanupBy(entity, by, values),
|
|
111
|
-
updateBy: (by, values, data) => updateBy(entity, by, values, data),
|
|
112
|
-
}),
|
|
113
|
-
});
|
|
114
|
-
};
|
|
4
|
+
return ({ databaseAdapter, db }) => {
|
|
5
|
+
function seedOne(entity) {
|
|
6
|
+
const generator = factories[entity];
|
|
7
|
+
return {
|
|
8
|
+
make: (data) => {
|
|
9
|
+
return generator(data);
|
|
10
|
+
},
|
|
11
|
+
save: async (data) => {
|
|
12
|
+
const value = generator(data);
|
|
13
|
+
if (databaseAdapter === "postgres") {
|
|
14
|
+
if (!db) throw new Error("Postgres database is not provided");
|
|
15
|
+
const pgTable = references[entity]?.postgres;
|
|
16
|
+
if (!pgTable) throw new Error(`No postgres reference for ${entity}`);
|
|
17
|
+
return (await db.insert(pgTable).values(value).returning())[0];
|
|
18
|
+
}
|
|
19
|
+
const model = references[entity]?.mongo;
|
|
20
|
+
if (!model?.create) throw new Error(`No mongo reference for ${entity}`);
|
|
21
|
+
return await model.create(value);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function seedMany(count, entity) {
|
|
26
|
+
const generator = factories[entity];
|
|
27
|
+
return {
|
|
28
|
+
make: (data) => {
|
|
29
|
+
return Array.from({ length: count }).map(() => generator(data));
|
|
30
|
+
},
|
|
31
|
+
save: async (data) => {
|
|
32
|
+
const values = Array.from({ length: count }).map(() => generator(data));
|
|
33
|
+
if (databaseAdapter === "postgres") {
|
|
34
|
+
if (!db) throw new Error("Postgres database is not provided");
|
|
35
|
+
const pgTable = references[entity]?.postgres;
|
|
36
|
+
if (!pgTable) throw new Error(`No postgres reference for ${entity}`);
|
|
37
|
+
return await db.insert(pgTable).values(values).returning();
|
|
38
|
+
}
|
|
39
|
+
const model = references[entity]?.mongo;
|
|
40
|
+
if (!model?.create) throw new Error(`No mongo reference for ${entity}`);
|
|
41
|
+
return await model.create(values);
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async function cleanupBy(entity, by, values) {
|
|
46
|
+
if (databaseAdapter === "postgres") {
|
|
47
|
+
if (!db) throw new Error("Postgres database is not provided");
|
|
48
|
+
const pgTable = references[entity]?.postgres;
|
|
49
|
+
if (!pgTable) throw new Error(`No postgres reference for ${entity}`);
|
|
50
|
+
const column = pgTable[by];
|
|
51
|
+
return await db.delete(pgTable).where(inArray(column, values)).returning();
|
|
52
|
+
}
|
|
53
|
+
const model = references[entity]?.mongo;
|
|
54
|
+
if (!model?.find || !model?.deleteMany) throw new Error(`No mongo reference for ${entity}`);
|
|
55
|
+
const deleted = await model.find({ [by === "id" ? "_id" : by]: { $in: values } });
|
|
56
|
+
await model.deleteMany({ [by === "id" ? "_id" : by]: { $in: values } });
|
|
57
|
+
return deleted;
|
|
58
|
+
}
|
|
59
|
+
async function updateBy(entity, by, values, data) {
|
|
60
|
+
if (databaseAdapter === "postgres") {
|
|
61
|
+
if (!db) throw new Error("Postgres database is not provided");
|
|
62
|
+
const pgTable = references[entity]?.postgres;
|
|
63
|
+
if (!pgTable) throw new Error(`No postgres reference for ${entity}`);
|
|
64
|
+
const column = pgTable[by];
|
|
65
|
+
return await db.update(pgTable).set(data).where(inArray(column, values)).returning();
|
|
66
|
+
}
|
|
67
|
+
const model = references[entity]?.mongo;
|
|
68
|
+
if (!model?.updateMany || !model?.find) throw new Error(`No mongo reference for ${entity}`);
|
|
69
|
+
await model.updateMany({ [by === "id" ? "_id" : by]: { $in: values } }, { $set: data });
|
|
70
|
+
return await model.find({ [by === "id" ? "_id" : by]: { $in: values } });
|
|
71
|
+
}
|
|
72
|
+
return new Proxy({}, { get: (_, entity) => ({
|
|
73
|
+
seed: {
|
|
74
|
+
...seedOne(entity),
|
|
75
|
+
many: (count) => seedMany(count, entity)
|
|
76
|
+
},
|
|
77
|
+
cleanupBy: (by, values) => cleanupBy(entity, by, values),
|
|
78
|
+
updateBy: (by, values, data) => updateBy(entity, by, values, data)
|
|
79
|
+
}) });
|
|
80
|
+
};
|
|
115
81
|
}
|
|
116
|
-
//#
|
|
82
|
+
//#endregion
|
|
83
|
+
export { buildDbUtilsFn };
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import documents from "./stubs/documents/index.js";
|
|
2
|
+
import lodash from "lodash";
|
|
3
|
+
//#region src/documentsGenerator.ts
|
|
4
|
+
const { camelCase, cloneDeep, merge } = lodash;
|
|
5
|
+
var DocumentsGenerator = class {
|
|
6
|
+
generateDocument(type, data) {
|
|
7
|
+
const document = documents[camelCase(type)];
|
|
8
|
+
if (!document) throw new Error(`Document ${type} is not supported at the moment. You can generate those documents [${Object.keys(documents).join(", ")}]`);
|
|
9
|
+
const clone = cloneDeep(document);
|
|
10
|
+
if (!data) return clone;
|
|
11
|
+
return merge(clone, data);
|
|
12
|
+
}
|
|
4
13
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const documents_1 = __importDefault(require("./stubs/documents"));
|
|
8
|
-
class DocumentsGenerator {
|
|
9
|
-
generateDocument(type, data) {
|
|
10
|
-
const document = documents_1.default[(0, lodash_1.camelCase)(type)];
|
|
11
|
-
if (!document) {
|
|
12
|
-
throw new Error(`Document ${type} is not supported at the moment. You can generate those documents [${Object.keys(documents_1.default)}]`);
|
|
13
|
-
}
|
|
14
|
-
const clone = (0, lodash_1.cloneDeep)(document);
|
|
15
|
-
if (!data) {
|
|
16
|
-
return clone;
|
|
17
|
-
}
|
|
18
|
-
return (0, lodash_1.merge)(clone, data);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
exports.default = DocumentsGenerator;
|
|
22
|
-
//# sourceMappingURL=documentsGenerator.js.map
|
|
14
|
+
//#endregion
|
|
15
|
+
export { DocumentsGenerator as default };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { DocumentsGenerator } from "./documentsGenerator.js";
|
|
2
|
+
import { PublicServiceGenerator } from "./publicServiceGenerator.js";
|
|
3
|
+
import { RandomGenerator } from "./randomGenerator.js";
|
|
4
|
+
import { SessionGenerator } from "./sessionGenerator.js";
|
|
5
|
+
import { buildDbUtilsFn } from "./dbUtilsBuilder.js";
|
|
6
|
+
|
|
7
|
+
//#region src/index.d.ts
|
|
8
|
+
declare class TestKit {
|
|
9
|
+
readonly session: SessionGenerator;
|
|
10
|
+
readonly random: RandomGenerator;
|
|
11
|
+
readonly docs: DocumentsGenerator;
|
|
12
|
+
readonly public: PublicServiceGenerator;
|
|
13
|
+
constructor();
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { SessionGenerator, buildDbUtilsFn, TestKit as default };
|
package/dist/index.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import DocumentsGenerator from "./documentsGenerator.js";
|
|
2
|
+
import PublicServiceGenerator from "./publicServiceGenerator.js";
|
|
3
|
+
import RandomGenerator from "./randomGenerator.js";
|
|
4
|
+
import SessionGenerator from "./sessionGenerator.js";
|
|
5
|
+
import { buildDbUtilsFn } from "./dbUtilsBuilder.js";
|
|
6
|
+
//#region src/index.ts
|
|
7
|
+
var TestKit = class {
|
|
8
|
+
session;
|
|
9
|
+
random;
|
|
10
|
+
docs;
|
|
11
|
+
public;
|
|
12
|
+
constructor() {
|
|
13
|
+
this.random = new RandomGenerator();
|
|
14
|
+
this.session = new SessionGenerator(this.random);
|
|
15
|
+
this.docs = new DocumentsGenerator();
|
|
16
|
+
this.public = new PublicServiceGenerator();
|
|
17
|
+
}
|
|
4
18
|
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const documentsGenerator_1 = __importDefault(require("./documentsGenerator"));
|
|
8
|
-
const publicServiceGenerator_1 = __importDefault(require("./publicServiceGenerator"));
|
|
9
|
-
const randomGenerator_1 = __importDefault(require("./randomGenerator"));
|
|
10
|
-
const sessionGenerator_1 = __importDefault(require("./sessionGenerator"));
|
|
11
|
-
class TestKit {
|
|
12
|
-
session;
|
|
13
|
-
random;
|
|
14
|
-
docs;
|
|
15
|
-
public;
|
|
16
|
-
constructor() {
|
|
17
|
-
this.random = new randomGenerator_1.default();
|
|
18
|
-
this.session = new sessionGenerator_1.default(this.random);
|
|
19
|
-
this.docs = new documentsGenerator_1.default();
|
|
20
|
-
this.public = new publicServiceGenerator_1.default();
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
exports.default = TestKit;
|
|
24
|
-
var sessionGenerator_2 = require("./sessionGenerator");
|
|
25
|
-
Object.defineProperty(exports, "SessionGenerator", { enumerable: true, get: function () { return __importDefault(sessionGenerator_2).default; } });
|
|
26
|
-
var dbUtilsBuilder_1 = require("./dbUtilsBuilder");
|
|
27
|
-
Object.defineProperty(exports, "buildDbUtilsFn", { enumerable: true, get: function () { return dbUtilsBuilder_1.buildDbUtilsFn; } });
|
|
28
|
-
//# sourceMappingURL=index.js.map
|
|
19
|
+
//#endregion
|
|
20
|
+
export { SessionGenerator, buildDbUtilsFn, TestKit as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { PublicServiceContextMenu, PublicServiceSettings } from "@diia-inhouse/design-system";
|
|
2
|
+
|
|
3
|
+
//#region src/publicServiceGenerator.d.ts
|
|
4
|
+
declare class PublicServiceGenerator {
|
|
5
|
+
getPublicServiceContextMenu(contextMenuItems?: PublicServiceContextMenu[]): PublicServiceContextMenu[];
|
|
6
|
+
getPublicServiceSettings(serviceSettings?: Partial<PublicServiceSettings>): PublicServiceSettings;
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { PublicServiceGenerator };
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { PublicServiceContextMenuType, PublicServiceStatus } from "@diia-inhouse/design-system";
|
|
2
|
+
//#region src/publicServiceGenerator.ts
|
|
3
|
+
var PublicServiceGenerator = class {
|
|
4
|
+
getPublicServiceContextMenu(contextMenuItems = []) {
|
|
5
|
+
return [{
|
|
6
|
+
type: PublicServiceContextMenuType.faqCategory,
|
|
7
|
+
name: "contextItemName"
|
|
8
|
+
}, ...contextMenuItems];
|
|
9
|
+
}
|
|
10
|
+
getPublicServiceSettings(serviceSettings = {}) {
|
|
11
|
+
return {
|
|
12
|
+
id: "123",
|
|
13
|
+
code: "penalties",
|
|
14
|
+
name: "penalties",
|
|
15
|
+
status: PublicServiceStatus.active,
|
|
16
|
+
contextMenu: this.getPublicServiceContextMenu(),
|
|
17
|
+
categories: [],
|
|
18
|
+
sortOrder: 0,
|
|
19
|
+
locales: {},
|
|
20
|
+
...serviceSettings
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { PublicServiceGenerator as default };
|
package/dist/randomGenerator.js
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.default = RandomGenerator;
|
|
18
|
-
//# sourceMappingURL=randomGenerator.js.map
|
|
1
|
+
import { randomInt } from "node:crypto";
|
|
2
|
+
//#region src/randomGenerator.ts
|
|
3
|
+
var RandomGenerator = class {
|
|
4
|
+
getRandomInt(minParam, maxParam) {
|
|
5
|
+
return randomInt(Math.ceil(minParam), Math.floor(maxParam) + 1);
|
|
6
|
+
}
|
|
7
|
+
getRandomIntByLength(length) {
|
|
8
|
+
let randomNumber = "";
|
|
9
|
+
for (let i = 0; i < length; i++) randomNumber += randomInt(10);
|
|
10
|
+
return Number(randomNumber);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
//#endregion
|
|
14
|
+
export { RandomGenerator as default };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RandomGenerator } from "./randomGenerator.js";
|
|
2
|
+
import { GetUserActionArgumentsOps } from "./interfaces/index.js";
|
|
3
|
+
import { AcquirerSession, AcquirerTokenData, ActionSession, AppUserActionHeaders, AuthEntryPoint, DiiaOfficeUserSession, EResidentApplicantSession, EResidentApplicantTokenData, EResidentSession, EResidentTokenData, Gender, PartnerSession, PartnerTokenData, PortalUserSession, PortalUserTokenData, ServiceEntranceSession, ServiceEntranceTokenData, ServiceUserSession, ServiceUserTokenData, SessionType, TemporarySession, TemporaryTokenData, UserActionArguments, UserSession, UserTokenData } from "@diia-inhouse/types";
|
|
4
|
+
|
|
5
|
+
//#region src/sessionGenerator.d.ts
|
|
6
|
+
declare class SessionGenerator {
|
|
7
|
+
private readonly random;
|
|
8
|
+
private readonly dateFormat;
|
|
9
|
+
constructor(random: RandomGenerator);
|
|
10
|
+
getUserActionArguments(user?: Partial<UserTokenData>, headers?: Partial<AppUserActionHeaders>, ops?: GetUserActionArgumentsOps): UserActionArguments;
|
|
11
|
+
getAuthEntryPoint(authEntryPoint?: Partial<AuthEntryPoint>): AuthEntryPoint;
|
|
12
|
+
getUserSession(tokenData?: Partial<UserTokenData>, validItn?: boolean): UserSession;
|
|
13
|
+
getDiiaOfficeUserSession(tokenData?: Partial<UserTokenData>, validItn?: boolean, features?: Record<string, unknown>): DiiaOfficeUserSession;
|
|
14
|
+
getEResidentSession(tokenData?: Partial<EResidentTokenData>, validItn?: boolean): EResidentSession;
|
|
15
|
+
getEResidentApplicantSession(tokenData?: Partial<EResidentApplicantTokenData>): EResidentApplicantSession;
|
|
16
|
+
/** @deprecated use getAcquirerSessionStringId after diia-app v15 */
|
|
17
|
+
getAcquirerSession(tokenData?: Partial<AcquirerTokenData>): AcquirerSession;
|
|
18
|
+
getAcquirerSessionStringId(tokenData?: Partial<AcquirerTokenData>): AcquirerSession;
|
|
19
|
+
/** @deprecated use getPartnerSessionStringId after diia-app v15 */
|
|
20
|
+
getPartnerSession(tokenData?: Partial<PartnerTokenData>): PartnerSession;
|
|
21
|
+
getPartnerSessionStringId(tokenData?: Partial<PartnerTokenData>): PartnerSession;
|
|
22
|
+
getTemporarySession(tokenData?: Partial<TemporaryTokenData>): TemporarySession;
|
|
23
|
+
getServiceEntranceSession(tokenData?: Partial<ServiceEntranceTokenData>): ServiceEntranceSession;
|
|
24
|
+
getPortalUserSession(tokenData?: Partial<PortalUserTokenData>, validItn?: boolean): PortalUserSession;
|
|
25
|
+
getServiceUserSession(tokenData?: Partial<ServiceUserTokenData>): ServiceUserSession;
|
|
26
|
+
getSessionBySessionType(sessionType: SessionType, tokenData?: {}, validItn?: boolean): ActionSession | undefined;
|
|
27
|
+
getHeaders(headers?: Partial<AppUserActionHeaders>): AppUserActionHeaders;
|
|
28
|
+
getBirthDate(): string;
|
|
29
|
+
getGender(): Gender;
|
|
30
|
+
generateItn(birthDate: string, gender: Gender, validItn: boolean): string;
|
|
31
|
+
private getUserData;
|
|
32
|
+
private getItnSeqNumber;
|
|
33
|
+
private isOdd;
|
|
34
|
+
private createIdentifier;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { SessionGenerator };
|