@sdflc/backend-helpers 1.0.104 → 1.0.106
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/package.json +25 -25
- package/build/BaseCore.d.ts +0 -88
- package/build/BaseCore.js +0 -723
- package/build/BaseGateway.d.ts +0 -56
- package/build/BaseGateway.js +0 -480
- package/build/DataCache.d.ts +0 -16
- package/build/DataCache.js +0 -112
- package/build/Database.d.ts +0 -36
- package/build/Database.js +0 -195
- package/build/DbMigratorAndSeeder.d.ts +0 -49
- package/build/DbMigratorAndSeeder.js +0 -212
- package/build/RedisDataLoader.d.ts +0 -41
- package/build/RedisDataLoader.js +0 -212
- package/build/apiContext.d.ts +0 -11
- package/build/apiContext.js +0 -146
- package/build/baseController.d.ts +0 -17
- package/build/baseController.js +0 -59
- package/build/checkItHelpers.d.ts +0 -3
- package/build/checkItHelpers.js +0 -28
- package/build/commonValidators.d.ts +0 -17
- package/build/commonValidators.js +0 -311
- package/build/configBulder.d.ts +0 -2
- package/build/configBulder.js +0 -36
- package/build/constants.d.ts +0 -30
- package/build/constants.js +0 -80
- package/build/dbHelpers.d.ts +0 -43
- package/build/dbHelpers.js +0 -156
- package/build/dbSeeder.d.ts +0 -2
- package/build/dbSeeder.js +0 -83
- package/build/dbTableHelpers.d.ts +0 -14
- package/build/dbTableHelpers.js +0 -118
- package/build/downloadHelpers.d.ts +0 -2
- package/build/downloadHelpers.js +0 -73
- package/build/esm/BaseCore.d.ts +0 -88
- package/build/esm/BaseCore.js +0 -717
- package/build/esm/BaseGateway.d.ts +0 -56
- package/build/esm/BaseGateway.js +0 -474
- package/build/esm/DataCache.d.ts +0 -16
- package/build/esm/DataCache.js +0 -106
- package/build/esm/Database.d.ts +0 -36
- package/build/esm/Database.js +0 -189
- package/build/esm/DbMigratorAndSeeder.d.ts +0 -49
- package/build/esm/DbMigratorAndSeeder.js +0 -173
- package/build/esm/RedisDataLoader.d.ts +0 -41
- package/build/esm/RedisDataLoader.js +0 -206
- package/build/esm/apiContext.d.ts +0 -11
- package/build/esm/apiContext.js +0 -138
- package/build/esm/baseController.d.ts +0 -17
- package/build/esm/baseController.js +0 -53
- package/build/esm/checkItHelpers.d.ts +0 -3
- package/build/esm/checkItHelpers.js +0 -23
- package/build/esm/commonValidators.d.ts +0 -17
- package/build/esm/commonValidators.js +0 -291
- package/build/esm/configBulder.d.ts +0 -2
- package/build/esm/configBulder.js +0 -32
- package/build/esm/constants.d.ts +0 -30
- package/build/esm/constants.js +0 -69
- package/build/esm/dbHelpers.d.ts +0 -43
- package/build/esm/dbHelpers.js +0 -144
- package/build/esm/dbSeeder.d.ts +0 -2
- package/build/esm/dbSeeder.js +0 -44
- package/build/esm/dbTableHelpers.d.ts +0 -14
- package/build/esm/dbTableHelpers.js +0 -106
- package/build/esm/downloadHelpers.d.ts +0 -2
- package/build/esm/downloadHelpers.js +0 -66
- package/build/esm/index.d.ts +0 -21
- package/build/esm/index.js +0 -21
- package/build/esm/interfaces/ApiContext.d.ts +0 -25
- package/build/esm/interfaces/ApiContext.js +0 -1
- package/build/esm/interfaces/ApiContextInterface.d.ts +0 -12
- package/build/esm/interfaces/ApiContextInterface.js +0 -1
- package/build/esm/interfaces/BaseCoreActionsInterface.d.ts +0 -38
- package/build/esm/interfaces/BaseCoreActionsInterface.js +0 -1
- package/build/esm/interfaces/BaseCoreDoAuthOnActionInterface.d.ts +0 -12
- package/build/esm/interfaces/BaseCoreDoAuthOnActionInterface.js +0 -1
- package/build/esm/interfaces/BaseCoreDoingWhatInterface.d.ts +0 -13
- package/build/esm/interfaces/BaseCoreDoingWhatInterface.js +0 -1
- package/build/esm/interfaces/BaseCorePropsInterface.d.ts +0 -37
- package/build/esm/interfaces/BaseCorePropsInterface.js +0 -1
- package/build/esm/interfaces/BaseCoreValidatorsInterface.d.ts +0 -13
- package/build/esm/interfaces/BaseCoreValidatorsInterface.js +0 -1
- package/build/esm/interfaces/BaseGatewayPropsInterface.d.ts +0 -39
- package/build/esm/interfaces/BaseGatewayPropsInterface.js +0 -1
- package/build/esm/interfaces/BuildConfigOptions.d.ts +0 -6
- package/build/esm/interfaces/BuildConfigOptions.js +0 -1
- package/build/esm/interfaces/BuildDefaultResolversOptions.d.ts +0 -17
- package/build/esm/interfaces/BuildDefaultResolversOptions.js +0 -1
- package/build/esm/interfaces/BuildListQueryArgsInterface.d.ts +0 -6
- package/build/esm/interfaces/BuildListQueryArgsInterface.js +0 -1
- package/build/esm/interfaces/CacheInterface.d.ts +0 -15
- package/build/esm/interfaces/CacheInterface.js +0 -1
- package/build/esm/interfaces/CommonValidatorArgs.d.ts +0 -3
- package/build/esm/interfaces/CommonValidatorArgs.js +0 -1
- package/build/esm/interfaces/CoreActionInterface.d.ts +0 -14
- package/build/esm/interfaces/CoreActionInterface.js +0 -1
- package/build/esm/interfaces/CreateUserTokenArgs.d.ts +0 -11
- package/build/esm/interfaces/CreateUserTokenArgs.js +0 -1
- package/build/esm/interfaces/CreateUserTokenResult.d.ts +0 -4
- package/build/esm/interfaces/CreateUserTokenResult.js +0 -1
- package/build/esm/interfaces/DatabaseOptions.d.ts +0 -26
- package/build/esm/interfaces/DatabaseOptions.js +0 -1
- package/build/esm/interfaces/DatabaseReadInterface.d.ts +0 -14
- package/build/esm/interfaces/DatabaseReadInterface.js +0 -1
- package/build/esm/interfaces/DbFieldAddDefaultInterface.d.ts +0 -9
- package/build/esm/interfaces/DbFieldAddDefaultInterface.js +0 -1
- package/build/esm/interfaces/DownloadFileArgs.d.ts +0 -6
- package/build/esm/interfaces/DownloadFileArgs.js +0 -1
- package/build/esm/interfaces/ExtractCredentialsArgs.d.ts +0 -19
- package/build/esm/interfaces/ExtractCredentialsArgs.js +0 -1
- package/build/esm/interfaces/JwtTokenSecretAndSettings.d.ts +0 -5
- package/build/esm/interfaces/JwtTokenSecretAndSettings.js +0 -1
- package/build/esm/interfaces/ListArgsInterface.d.ts +0 -7
- package/build/esm/interfaces/ListArgsInterface.js +0 -1
- package/build/esm/interfaces/LoaderInterface.d.ts +0 -7
- package/build/esm/interfaces/LoaderInterface.js +0 -1
- package/build/esm/interfaces/PaginationInterface.d.ts +0 -10
- package/build/esm/interfaces/PaginationInterface.js +0 -1
- package/build/esm/interfaces/SortItemInterface.d.ts +0 -4
- package/build/esm/interfaces/SortItemInterface.js +0 -1
- package/build/esm/interfaces/UserTokenParams.d.ts +0 -8
- package/build/esm/interfaces/UserTokenParams.js +0 -1
- package/build/esm/interfaces/VerifyUserTokenArgs.d.ts +0 -13
- package/build/esm/interfaces/VerifyUserTokenArgs.js +0 -1
- package/build/esm/interfaces/index.d.ts +0 -28
- package/build/esm/interfaces/index.js +0 -27
- package/build/esm/knexConfigBuilder.d.ts +0 -1
- package/build/esm/knexConfigBuilder.js +0 -84
- package/build/esm/passwordHelpers.d.ts +0 -5
- package/build/esm/passwordHelpers.js +0 -13
- package/build/esm/redisClient.d.ts +0 -17
- package/build/esm/redisClient.js +0 -94
- package/build/esm/resolversHelpers.d.ts +0 -3
- package/build/esm/resolversHelpers.js +0 -66
- package/build/esm/userToken.d.ts +0 -8
- package/build/esm/userToken.js +0 -74
- package/build/esm/utils.d.ts +0 -2
- package/build/esm/utils.js +0 -13
- package/build/index.d.ts +0 -21
- package/build/index.js +0 -37
- package/build/interfaces/ApiContext.d.ts +0 -25
- package/build/interfaces/ApiContext.js +0 -2
- package/build/interfaces/ApiContextInterface.d.ts +0 -12
- package/build/interfaces/ApiContextInterface.js +0 -2
- package/build/interfaces/BaseCoreActionsInterface.d.ts +0 -38
- package/build/interfaces/BaseCoreActionsInterface.js +0 -2
- package/build/interfaces/BaseCoreDoAuthOnActionInterface.d.ts +0 -12
- package/build/interfaces/BaseCoreDoAuthOnActionInterface.js +0 -2
- package/build/interfaces/BaseCoreDoingWhatInterface.d.ts +0 -13
- package/build/interfaces/BaseCoreDoingWhatInterface.js +0 -2
- package/build/interfaces/BaseCorePropsInterface.d.ts +0 -37
- package/build/interfaces/BaseCorePropsInterface.js +0 -2
- package/build/interfaces/BaseCoreValidatorsInterface.d.ts +0 -13
- package/build/interfaces/BaseCoreValidatorsInterface.js +0 -2
- package/build/interfaces/BaseGatewayPropsInterface.d.ts +0 -39
- package/build/interfaces/BaseGatewayPropsInterface.js +0 -2
- package/build/interfaces/BuildConfigOptions.d.ts +0 -6
- package/build/interfaces/BuildConfigOptions.js +0 -2
- package/build/interfaces/BuildDefaultResolversOptions.d.ts +0 -17
- package/build/interfaces/BuildDefaultResolversOptions.js +0 -2
- package/build/interfaces/BuildListQueryArgsInterface.d.ts +0 -6
- package/build/interfaces/BuildListQueryArgsInterface.js +0 -2
- package/build/interfaces/CacheInterface.d.ts +0 -15
- package/build/interfaces/CacheInterface.js +0 -2
- package/build/interfaces/CommonValidatorArgs.d.ts +0 -3
- package/build/interfaces/CommonValidatorArgs.js +0 -2
- package/build/interfaces/CoreActionInterface.d.ts +0 -14
- package/build/interfaces/CoreActionInterface.js +0 -2
- package/build/interfaces/CreateUserTokenArgs.d.ts +0 -11
- package/build/interfaces/CreateUserTokenArgs.js +0 -2
- package/build/interfaces/CreateUserTokenResult.d.ts +0 -4
- package/build/interfaces/CreateUserTokenResult.js +0 -2
- package/build/interfaces/DatabaseOptions.d.ts +0 -26
- package/build/interfaces/DatabaseOptions.js +0 -2
- package/build/interfaces/DatabaseReadInterface.d.ts +0 -14
- package/build/interfaces/DatabaseReadInterface.js +0 -2
- package/build/interfaces/DbFieldAddDefaultInterface.d.ts +0 -9
- package/build/interfaces/DbFieldAddDefaultInterface.js +0 -2
- package/build/interfaces/DownloadFileArgs.d.ts +0 -6
- package/build/interfaces/DownloadFileArgs.js +0 -2
- package/build/interfaces/ExtractCredentialsArgs.d.ts +0 -19
- package/build/interfaces/ExtractCredentialsArgs.js +0 -2
- package/build/interfaces/JwtTokenSecretAndSettings.d.ts +0 -5
- package/build/interfaces/JwtTokenSecretAndSettings.js +0 -2
- package/build/interfaces/ListArgsInterface.d.ts +0 -7
- package/build/interfaces/ListArgsInterface.js +0 -2
- package/build/interfaces/LoaderInterface.d.ts +0 -7
- package/build/interfaces/LoaderInterface.js +0 -2
- package/build/interfaces/PaginationInterface.d.ts +0 -10
- package/build/interfaces/PaginationInterface.js +0 -2
- package/build/interfaces/SortItemInterface.d.ts +0 -4
- package/build/interfaces/SortItemInterface.js +0 -2
- package/build/interfaces/UserTokenParams.d.ts +0 -8
- package/build/interfaces/UserTokenParams.js +0 -2
- package/build/interfaces/VerifyUserTokenArgs.d.ts +0 -13
- package/build/interfaces/VerifyUserTokenArgs.js +0 -2
- package/build/interfaces/index.d.ts +0 -28
- package/build/interfaces/index.js +0 -43
- package/build/knexConfigBuilder.d.ts +0 -1
- package/build/knexConfigBuilder.js +0 -91
- package/build/passwordHelpers.d.ts +0 -5
- package/build/passwordHelpers.js +0 -21
- package/build/redisClient.d.ts +0 -17
- package/build/redisClient.js +0 -97
- package/build/resolversHelpers.d.ts +0 -3
- package/build/resolversHelpers.js +0 -69
- package/build/userToken.d.ts +0 -8
- package/build/userToken.js +0 -86
- package/build/utils.d.ts +0 -2
- package/build/utils.js +0 -21
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
const buildDefaultResolvers = (args) => {
|
|
2
|
-
const { prefix, core, query, mutation, types, disableList, disableGet, disableGetMany, disableCreate, disableCreateMany, disableUpdate, disableUpdateMany, disableSet, disableRemove, disableRemoveMany, } = args || {};
|
|
3
|
-
const Query = {
|
|
4
|
-
...(query || {}),
|
|
5
|
-
};
|
|
6
|
-
const Mutation = {
|
|
7
|
-
...(mutation || {}),
|
|
8
|
-
};
|
|
9
|
-
const coreToUse = core || `${prefix}Core`;
|
|
10
|
-
if (disableList !== true) {
|
|
11
|
-
Query[`${prefix}List`] = (parent, args, context) => {
|
|
12
|
-
return context.cores[coreToUse].list(args);
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
if (disableGet !== true) {
|
|
16
|
-
Query[`${prefix}Get`] = (parent, args, context) => {
|
|
17
|
-
return context.cores[coreToUse].get(args);
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
if (disableGetMany !== true) {
|
|
21
|
-
Query[`${prefix}GetMany`] = (parent, args, context) => {
|
|
22
|
-
return context.cores[coreToUse].getMany(args);
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
if (disableCreate !== true) {
|
|
26
|
-
Mutation[`${prefix}Create`] = (parent, args, context) => {
|
|
27
|
-
return context.cores[coreToUse].create(args);
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
if (disableCreateMany !== true) {
|
|
31
|
-
Mutation[`${prefix}CreateMany`] = (parent, args, context) => {
|
|
32
|
-
return context.cores[coreToUse].createMany(args);
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
if (disableUpdate !== true) {
|
|
36
|
-
Mutation[`${prefix}Update`] = (parent, args, context) => {
|
|
37
|
-
return context.cores[coreToUse].update(args);
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
if (disableUpdateMany !== true) {
|
|
41
|
-
Mutation[`${prefix}UpdateMany`] = (parent, args, context) => {
|
|
42
|
-
return context.cores[coreToUse].updateMany(args);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
if (disableSet !== true) {
|
|
46
|
-
Mutation[`${prefix}Set`] = (parent, args, context) => {
|
|
47
|
-
return context.cores[coreToUse].set(args);
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
if (disableRemove !== true) {
|
|
51
|
-
Mutation[`${prefix}Remove`] = (parent, args, context) => {
|
|
52
|
-
return context.cores[coreToUse].remove(args);
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (disableRemoveMany !== true) {
|
|
56
|
-
Mutation[`${prefix}RemoveMany`] = (parent, args, context) => {
|
|
57
|
-
return context.cores[coreToUse].removeMany(args);
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
Query,
|
|
62
|
-
Mutation,
|
|
63
|
-
...(types || {}),
|
|
64
|
-
};
|
|
65
|
-
};
|
|
66
|
-
export { buildDefaultResolvers };
|
package/build/esm/userToken.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { OpResult } from '@sdflc/api-helpers';
|
|
2
|
-
import { UserTokenParams, CreateUserTokenArgs, VerifyUserTokenArgs } from './interfaces';
|
|
3
|
-
export declare const setDefaultJwtAlgorithm: (algorithm: string) => void;
|
|
4
|
-
export declare const getDefaultJwtAlgorithm: () => string;
|
|
5
|
-
export declare const setDefaultJwtIssuer: (issuer: string) => void;
|
|
6
|
-
export declare const getDefaultJwtIssuer: () => string;
|
|
7
|
-
export declare const createUserToken: (params: UserTokenParams, secret: string, opt: CreateUserTokenArgs) => any;
|
|
8
|
-
export declare const verifyUserToken: (token: string, secret: string, args?: VerifyUserTokenArgs) => OpResult;
|
package/build/esm/userToken.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
import jwt from 'jsonwebtoken';
|
|
2
|
-
import { v4 as uuid } from 'uuid';
|
|
3
|
-
import { OpResult, OP_RESULT_CODES } from '@sdflc/api-helpers';
|
|
4
|
-
import { DEFAULT_JWT_ISSUER, DEFAULT_JWT_ALGORITHM } from './constants';
|
|
5
|
-
import dayjs from 'dayjs';
|
|
6
|
-
let defaultJwtAlgorithm = DEFAULT_JWT_ALGORITHM;
|
|
7
|
-
let defaultIssuer = DEFAULT_JWT_ISSUER;
|
|
8
|
-
export const setDefaultJwtAlgorithm = (algorithm) => {
|
|
9
|
-
defaultJwtAlgorithm = algorithm;
|
|
10
|
-
};
|
|
11
|
-
export const getDefaultJwtAlgorithm = () => {
|
|
12
|
-
return defaultJwtAlgorithm;
|
|
13
|
-
};
|
|
14
|
-
export const setDefaultJwtIssuer = (issuer) => {
|
|
15
|
-
defaultIssuer = issuer;
|
|
16
|
-
};
|
|
17
|
-
export const getDefaultJwtIssuer = () => {
|
|
18
|
-
return defaultIssuer;
|
|
19
|
-
};
|
|
20
|
-
export const createUserToken = (params, secret, opt) => {
|
|
21
|
-
const { algorithm, audience, issuer, jwtid, noTimestamp, header, keyid, expiresIn, useFingerprint } = opt || {};
|
|
22
|
-
if (!params || !secret) {
|
|
23
|
-
return OpResult.fail(OP_RESULT_CODES.VALIDATION_FAILED, null, 'Failed to create user JWT');
|
|
24
|
-
}
|
|
25
|
-
if (useFingerprint) {
|
|
26
|
-
const fingerprint = uuid();
|
|
27
|
-
params['fingerprint'] = fingerprint;
|
|
28
|
-
}
|
|
29
|
-
const token = jwt.sign(params, secret, {
|
|
30
|
-
algorithm: algorithm || defaultJwtAlgorithm,
|
|
31
|
-
audience,
|
|
32
|
-
issuer: issuer || defaultIssuer,
|
|
33
|
-
jwtid: jwtid || uuid(),
|
|
34
|
-
subject: params.userId,
|
|
35
|
-
noTimestamp: noTimestamp ?? false,
|
|
36
|
-
header,
|
|
37
|
-
keyid,
|
|
38
|
-
expiresIn: expiresIn && !isNaN(expiresIn) ? expiresIn : undefined,
|
|
39
|
-
});
|
|
40
|
-
return OpResult.ok({ token, fingerprint: params.fingerprint });
|
|
41
|
-
};
|
|
42
|
-
export const verifyUserToken = (token, secret, args) => {
|
|
43
|
-
const { algorithms, audience, issuer, ignoreExpiration, ignoreNotBefore, subject, clockTolerance, maxAge, clockTimestamp, nonce, fingerprint, } = args || {};
|
|
44
|
-
if (!args) {
|
|
45
|
-
return OpResult.fail(OP_RESULT_CODES.VALIDATION_FAILED, null, 'Cannot verify user token as there are no parameters specified');
|
|
46
|
-
}
|
|
47
|
-
try {
|
|
48
|
-
const obj = jwt.verify(token, secret, {
|
|
49
|
-
algorithms: algorithms || [defaultJwtAlgorithm],
|
|
50
|
-
audience,
|
|
51
|
-
issuer: issuer || defaultIssuer,
|
|
52
|
-
ignoreExpiration,
|
|
53
|
-
ignoreNotBefore,
|
|
54
|
-
subject,
|
|
55
|
-
clockTolerance,
|
|
56
|
-
maxAge,
|
|
57
|
-
clockTimestamp,
|
|
58
|
-
nonce,
|
|
59
|
-
});
|
|
60
|
-
if (obj?.fingerprint && obj.fingerprint != fingerprint) {
|
|
61
|
-
return OpResult.fail(OP_RESULT_CODES.UNAUTHORIZED, null, 'User unauthenticated');
|
|
62
|
-
}
|
|
63
|
-
return OpResult.ok(obj);
|
|
64
|
-
}
|
|
65
|
-
catch (ex) {
|
|
66
|
-
if (ex.name === 'TokenExpiredError') {
|
|
67
|
-
return OpResult.fail(OP_RESULT_CODES.EXPIRED, null, `User authorization has expired at ${dayjs(ex.expiredAt).toDate()}`);
|
|
68
|
-
}
|
|
69
|
-
else if (ex.name === 'JsonWebTokenError') {
|
|
70
|
-
return OpResult.fail(OP_RESULT_CODES.EXPIRED, null, `JWT is invalid, reason: ${ex.message}`);
|
|
71
|
-
}
|
|
72
|
-
return OpResult.fail(OP_RESULT_CODES.UNAUTHORIZED, null, 'User unauthenticated');
|
|
73
|
-
}
|
|
74
|
-
};
|
package/build/esm/utils.d.ts
DELETED
package/build/esm/utils.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import check from 'check-types';
|
|
2
|
-
export const setFunction = (func, defaultFunc) => {
|
|
3
|
-
return check.function(func) ? func : defaultFunc;
|
|
4
|
-
};
|
|
5
|
-
export const setFunctions = (obj, defaultFuncs = {}) => {
|
|
6
|
-
const keys = Object.keys(defaultFuncs || {});
|
|
7
|
-
return keys.reduce((acc, key) => {
|
|
8
|
-
if (check.function(obj[key])) {
|
|
9
|
-
acc[key] = obj[key];
|
|
10
|
-
}
|
|
11
|
-
return acc;
|
|
12
|
-
}, {});
|
|
13
|
-
};
|
package/build/index.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export * from './constants';
|
|
2
|
-
export * from './interfaces';
|
|
3
|
-
export * from './configBulder';
|
|
4
|
-
export * from './Database';
|
|
5
|
-
export * from './dbHelpers';
|
|
6
|
-
export * from './DbMigratorAndSeeder';
|
|
7
|
-
export * from './dbSeeder';
|
|
8
|
-
export * from './knexConfigBuilder';
|
|
9
|
-
export * from './redisClient';
|
|
10
|
-
export * from './checkItHelpers';
|
|
11
|
-
export * from './DataCache';
|
|
12
|
-
export * from './BaseGateway';
|
|
13
|
-
export * from './BaseCore';
|
|
14
|
-
export * from './apiContext';
|
|
15
|
-
export * from './baseController';
|
|
16
|
-
export * from './dbTableHelpers';
|
|
17
|
-
export * from './resolversHelpers';
|
|
18
|
-
export * from './userToken';
|
|
19
|
-
export * from './passwordHelpers';
|
|
20
|
-
export * from './commonValidators';
|
|
21
|
-
export * from './downloadHelpers';
|
package/build/index.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./constants"), exports);
|
|
18
|
-
__exportStar(require("./interfaces"), exports);
|
|
19
|
-
__exportStar(require("./configBulder"), exports);
|
|
20
|
-
__exportStar(require("./Database"), exports);
|
|
21
|
-
__exportStar(require("./dbHelpers"), exports);
|
|
22
|
-
__exportStar(require("./DbMigratorAndSeeder"), exports);
|
|
23
|
-
__exportStar(require("./dbSeeder"), exports);
|
|
24
|
-
__exportStar(require("./knexConfigBuilder"), exports);
|
|
25
|
-
__exportStar(require("./redisClient"), exports);
|
|
26
|
-
__exportStar(require("./checkItHelpers"), exports);
|
|
27
|
-
__exportStar(require("./DataCache"), exports);
|
|
28
|
-
__exportStar(require("./BaseGateway"), exports);
|
|
29
|
-
__exportStar(require("./BaseCore"), exports);
|
|
30
|
-
__exportStar(require("./apiContext"), exports);
|
|
31
|
-
__exportStar(require("./baseController"), exports);
|
|
32
|
-
__exportStar(require("./dbTableHelpers"), exports);
|
|
33
|
-
__exportStar(require("./resolversHelpers"), exports);
|
|
34
|
-
__exportStar(require("./userToken"), exports);
|
|
35
|
-
__exportStar(require("./passwordHelpers"), exports);
|
|
36
|
-
__exportStar(require("./commonValidators"), exports);
|
|
37
|
-
__exportStar(require("./downloadHelpers"), exports);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface of application API interface which should be created on receiving of a request
|
|
3
|
-
*/
|
|
4
|
-
export interface ApiContext {
|
|
5
|
-
requestId: string;
|
|
6
|
-
cores: any;
|
|
7
|
-
gateways: any;
|
|
8
|
-
req: any;
|
|
9
|
-
res?: any;
|
|
10
|
-
spaceId?: string;
|
|
11
|
-
apiKey?: string;
|
|
12
|
-
managementApiKey?: string;
|
|
13
|
-
userAgent?: string;
|
|
14
|
-
referer?: string;
|
|
15
|
-
ipAddress?: string;
|
|
16
|
-
acceptLanguage?: string;
|
|
17
|
-
languages?: string[];
|
|
18
|
-
requestedLang?: string;
|
|
19
|
-
authorization?: string;
|
|
20
|
-
accountId?: string;
|
|
21
|
-
roleId?: string;
|
|
22
|
-
userId?: string;
|
|
23
|
-
lang?: string;
|
|
24
|
-
[key: string]: any;
|
|
25
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BaseCorePropsInterface } from './BaseCorePropsInterface';
|
|
2
|
-
import { BaseGatewayPropsInterface } from './BaseGatewayPropsInterface';
|
|
3
|
-
export interface ApiContextInterface {
|
|
4
|
-
cores: any;
|
|
5
|
-
gateways: any;
|
|
6
|
-
req: any;
|
|
7
|
-
res: any;
|
|
8
|
-
requestId: any;
|
|
9
|
-
getCoreContext?(args: any): Promise<BaseCorePropsInterface>;
|
|
10
|
-
getGatewayContext?(args: any): Promise<BaseGatewayPropsInterface>;
|
|
11
|
-
extendContext?(args: any): any;
|
|
12
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BaseCore } from '..';
|
|
2
|
-
export interface BaseCoreActionsInterface {
|
|
3
|
-
/**
|
|
4
|
-
* Reference to the core object that processes the request
|
|
5
|
-
*/
|
|
6
|
-
core: BaseCore;
|
|
7
|
-
/**
|
|
8
|
-
* Sets current step when processing an action
|
|
9
|
-
* @param str Name of step
|
|
10
|
-
*/
|
|
11
|
-
setStep?(str: string): void;
|
|
12
|
-
/**
|
|
13
|
-
* The sameRequest is true when we call a core method when handling the same request (actual for GraphQL resolvers)
|
|
14
|
-
*/
|
|
15
|
-
sameRequest?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* The transaction is active when processing some of actions that configured to open transaction
|
|
18
|
-
*/
|
|
19
|
-
hasTransaction?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* The validatedItems exists after validator execution.
|
|
22
|
-
* It is expected that validator return an array in which second element is some
|
|
23
|
-
* items that were read from data or created otherwise during validation
|
|
24
|
-
*/
|
|
25
|
-
validatedItems?: any;
|
|
26
|
-
/**
|
|
27
|
-
* The exception object exists only when exception happened when processing an action
|
|
28
|
-
*/
|
|
29
|
-
exception?: any;
|
|
30
|
-
/**
|
|
31
|
-
* Name of action for exception error messages
|
|
32
|
-
*/
|
|
33
|
-
doingWhat?: string;
|
|
34
|
-
/**
|
|
35
|
-
* Object with incoming request params
|
|
36
|
-
*/
|
|
37
|
-
args?: any;
|
|
38
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface BaseCoreDoAuthOnActionInterface {
|
|
2
|
-
list?: boolean;
|
|
3
|
-
get?: boolean;
|
|
4
|
-
getMany?: boolean;
|
|
5
|
-
create?: boolean;
|
|
6
|
-
createMany?: boolean;
|
|
7
|
-
update?: boolean;
|
|
8
|
-
updateMany?: boolean;
|
|
9
|
-
set?: boolean;
|
|
10
|
-
remove?: boolean;
|
|
11
|
-
removeMany?: boolean;
|
|
12
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface BaseCoreDoingWhatInterface {
|
|
2
|
-
list: string;
|
|
3
|
-
get: string;
|
|
4
|
-
getMany: string;
|
|
5
|
-
create: string;
|
|
6
|
-
createMany: string;
|
|
7
|
-
update: string;
|
|
8
|
-
updateMany: string;
|
|
9
|
-
set: string;
|
|
10
|
-
remove: string;
|
|
11
|
-
removeMany: string;
|
|
12
|
-
[key: string]: string;
|
|
13
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@sdflc/utils';
|
|
2
|
-
import { Database } from '../Database';
|
|
3
|
-
import { BaseGateway } from '../BaseGateway';
|
|
4
|
-
import { BaseCoreValidatorsInterface } from './BaseCoreValidatorsInterface';
|
|
5
|
-
import { BaseCoreDoingWhatInterface } from './BaseCoreDoingWhatInterface';
|
|
6
|
-
import { VerifyUserTokenArgs } from './VerifyUserTokenArgs';
|
|
7
|
-
import { ApiContext } from './ApiContext';
|
|
8
|
-
import { ID_TYPES } from '../constants';
|
|
9
|
-
import { BaseCoreDoAuthOnActionInterface } from './BaseCoreDoAuthOnActionInterface';
|
|
10
|
-
export interface BaseCorePropsInterface {
|
|
11
|
-
/**
|
|
12
|
-
* Application API context with all necessary information about request
|
|
13
|
-
*/
|
|
14
|
-
context: ApiContext;
|
|
15
|
-
/**
|
|
16
|
-
* Database instance to handle queries to DB within one request
|
|
17
|
-
*/
|
|
18
|
-
db: Database;
|
|
19
|
-
/**
|
|
20
|
-
* Name of a gateway that will perform default CRUD operations, it should be initialized in the API context
|
|
21
|
-
*/
|
|
22
|
-
gatewayName: string;
|
|
23
|
-
isProduction: boolean;
|
|
24
|
-
logger: Logger;
|
|
25
|
-
name?: string;
|
|
26
|
-
doAuth: boolean;
|
|
27
|
-
doAuthOnAction?: BaseCoreDoAuthOnActionInterface;
|
|
28
|
-
doingWhat?: BaseCoreDoingWhatInterface;
|
|
29
|
-
validators?: BaseCoreValidatorsInterface;
|
|
30
|
-
spaceGw?: BaseGateway;
|
|
31
|
-
interserviceApiKey?: string;
|
|
32
|
-
jwtSecret?: string;
|
|
33
|
-
verifyTokenArgs?: VerifyUserTokenArgs;
|
|
34
|
-
hasOrderNo?: boolean;
|
|
35
|
-
orderNoAsDecimal?: boolean;
|
|
36
|
-
idType?: ID_TYPES;
|
|
37
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { BaseCoreActionsInterface } from './BaseCoreActionsInterface';
|
|
2
|
-
export interface BaseCoreValidatorsInterface {
|
|
3
|
-
list?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
4
|
-
get?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
5
|
-
getMany?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
6
|
-
create?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
7
|
-
createMany?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
8
|
-
update?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
9
|
-
updateMany?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
10
|
-
set?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
11
|
-
remove?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
12
|
-
removeMany?(params: any, opt?: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
13
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@sdflc/utils';
|
|
2
|
-
import { ApiContext } from '.';
|
|
3
|
-
import { CacheInterface } from '..';
|
|
4
|
-
import { LoaderInterface } from './LoaderInterface';
|
|
5
|
-
import { SortItemInterface } from './SortItemInterface';
|
|
6
|
-
export interface BaseGatewayPropsInterface extends CacheInterface {
|
|
7
|
-
context: ApiContext;
|
|
8
|
-
table?: string;
|
|
9
|
-
idField?: string;
|
|
10
|
-
idFieldUpdateRemove?: string;
|
|
11
|
-
idFieldAs?: string;
|
|
12
|
-
setFields?: string[] | string;
|
|
13
|
-
mergeFields?: string[];
|
|
14
|
-
hasStatus?: boolean;
|
|
15
|
-
hasCreatedBy?: boolean;
|
|
16
|
-
hasUpdatedBy?: boolean;
|
|
17
|
-
hasRemovedBy?: boolean;
|
|
18
|
-
hasCreatedAt?: boolean;
|
|
19
|
-
hasUpdatedAt?: boolean;
|
|
20
|
-
hasRemovedAt?: boolean;
|
|
21
|
-
hasRemovedAtStr?: boolean;
|
|
22
|
-
hasSpace?: boolean;
|
|
23
|
-
hasVersion?: boolean;
|
|
24
|
-
hasLang?: boolean;
|
|
25
|
-
hasUserId?: boolean;
|
|
26
|
-
localizationForField?: string;
|
|
27
|
-
defaultSorting?: SortItemInterface[];
|
|
28
|
-
fieldForKeyword?: string;
|
|
29
|
-
filterByUserField?: string;
|
|
30
|
-
insertChunkSize?: number;
|
|
31
|
-
hardRemove?: boolean;
|
|
32
|
-
loader?: LoaderInterface;
|
|
33
|
-
noCache?: boolean;
|
|
34
|
-
returnFields?: any[];
|
|
35
|
-
activeStatuses?: number[];
|
|
36
|
-
logger: Logger;
|
|
37
|
-
isProduction: boolean;
|
|
38
|
-
usedKeyPrefixes?: any;
|
|
39
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface BuildDefaultResolvers {
|
|
2
|
-
prefix: string;
|
|
3
|
-
core: string;
|
|
4
|
-
query?: any;
|
|
5
|
-
mutation?: any;
|
|
6
|
-
types?: any;
|
|
7
|
-
disableList?: boolean;
|
|
8
|
-
disableGet?: boolean;
|
|
9
|
-
disableGetMany?: boolean;
|
|
10
|
-
disableCreate?: boolean;
|
|
11
|
-
disableCreateMany?: boolean;
|
|
12
|
-
disableUpdate?: boolean;
|
|
13
|
-
disableUpdateMany?: boolean;
|
|
14
|
-
disableSet?: boolean;
|
|
15
|
-
disableRemove?: boolean;
|
|
16
|
-
disableRemoveMany?: boolean;
|
|
17
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { Database } from '../Database';
|
|
2
|
-
export interface CacheInterface {
|
|
3
|
-
db: Database;
|
|
4
|
-
keyPrefix?: string;
|
|
5
|
-
context?: any;
|
|
6
|
-
table?: string;
|
|
7
|
-
idField?: string;
|
|
8
|
-
idFieldAs?: string;
|
|
9
|
-
selectFields?: any[];
|
|
10
|
-
readAll?: boolean;
|
|
11
|
-
redisClient?: any;
|
|
12
|
-
cacheTtl?: number;
|
|
13
|
-
loaderFn?(args?: any): any;
|
|
14
|
-
buildKey?(args: any): string;
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { BaseCoreActionsInterface } from './BaseCoreActionsInterface';
|
|
2
|
-
export interface CoreActionInterface {
|
|
3
|
-
args: any;
|
|
4
|
-
actionName?: string;
|
|
5
|
-
doAuth?: boolean;
|
|
6
|
-
accessRights?: any[];
|
|
7
|
-
validate?(args: any, opt: BaseCoreActionsInterface): Promise<any[]> | any[];
|
|
8
|
-
action(args?: any, opt?: any): any;
|
|
9
|
-
hasTransaction: boolean;
|
|
10
|
-
doingWhat?: string;
|
|
11
|
-
onException?(params: any, opt?: BaseCoreActionsInterface): Promise<any | undefined | null>;
|
|
12
|
-
shouldLogArgs?: boolean;
|
|
13
|
-
requireSpace?: boolean;
|
|
14
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Logger } from '@sdflc/utils';
|
|
2
|
-
/**
|
|
3
|
-
* Interface to initialize Database object
|
|
4
|
-
*/
|
|
5
|
-
export interface DatabaseOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Knex configuration object
|
|
8
|
-
*/
|
|
9
|
-
knexConfig: any;
|
|
10
|
-
/**
|
|
11
|
-
* Database type: pg, msql, etc
|
|
12
|
-
*/
|
|
13
|
-
dbType: string;
|
|
14
|
-
/**
|
|
15
|
-
* Name of database schema
|
|
16
|
-
*/
|
|
17
|
-
dbSchema: string;
|
|
18
|
-
/**
|
|
19
|
-
* Knex transaction object
|
|
20
|
-
*/
|
|
21
|
-
trx?: any;
|
|
22
|
-
/**
|
|
23
|
-
* Logger for debugging/logging
|
|
24
|
-
*/
|
|
25
|
-
logger?: Logger;
|
|
26
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Interface for Database.ReadAll method
|
|
3
|
-
*/
|
|
4
|
-
export interface DatabaseReadInterface {
|
|
5
|
-
table?: string;
|
|
6
|
-
selectFields?: string[];
|
|
7
|
-
sortBy?: any;
|
|
8
|
-
where?: any;
|
|
9
|
-
whereIn?: any;
|
|
10
|
-
extendQuery?(query: any): any;
|
|
11
|
-
mapBy?: string;
|
|
12
|
-
calculated?: any[];
|
|
13
|
-
buildKey?(key: string): string;
|
|
14
|
-
}
|