@friggframework/core 0.2.31-v1-alpha-package-update.0 → 1.0.1-canary.278.7b20420.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/assertions/CHANGELOG.md +87 -0
- package/assertions/LICENSE.md +9 -0
- package/assertions/README.md +3 -0
- package/assertions/bump.txt +1 -0
- package/assertions/get.js +139 -0
- package/assertions/index.js +19 -0
- package/assertions/is-equal.js +17 -0
- package/associations/LICENSE.md +9 -0
- package/associations/README.md +3 -0
- package/associations/association.js +78 -0
- package/associations/bump3.txt +0 -0
- package/associations/jest.config.js +5 -0
- package/associations/model.js +54 -0
- package/bump0.txt +1 -0
- package/core/.eslintrc.json +3 -0
- package/{Delegate.js → core/Delegate.js} +1 -1
- package/core/LICENSE.md +9 -0
- package/{Worker.js → core/Worker.js} +2 -2
- package/core/bump3.txt +0 -0
- package/{create-handler.js → core/create-handler.js} +2 -2
- package/core/index.js +6 -0
- package/core/jest.config.js +5 -0
- package/database/.eslintrc.json +3 -0
- package/database/CHANGELOG.md +97 -0
- package/database/LICENSE.md +9 -0
- package/database/README.md +3 -0
- package/database/bump3.txt +0 -0
- package/database/index.js +23 -0
- package/database/jest.config.js +5 -0
- package/database/models/IndividualUser.js +76 -0
- package/database/models/OrganizationUser.js +29 -0
- package/database/models/State.js +9 -0
- package/database/models/Token.js +70 -0
- package/database/models/UserModel.js +7 -0
- package/database/mongo.js +45 -0
- package/database/mongoose.js +5 -0
- package/encrypt/.eslintrc.json +3 -0
- package/encrypt/CHANGELOG.md +78 -0
- package/encrypt/Cryptor.js +236 -0
- package/encrypt/Cryptor.test.js +32 -0
- package/encrypt/LICENSE.md +9 -0
- package/encrypt/README.md +13 -0
- package/encrypt/aes.js +27 -0
- package/encrypt/bump3.txt +0 -0
- package/encrypt/encrypt.js +132 -0
- package/encrypt/encrypt.test.js +1069 -0
- package/encrypt/index.js +4 -0
- package/encrypt/jest.config.js +5 -0
- package/encrypt/test-encrypt.js +107 -0
- package/errors/.eslintrc.json +3 -0
- package/errors/CHANGELOG.md +44 -0
- package/errors/LICENSE.md +9 -0
- package/errors/README.md +3 -0
- package/errors/base-error.js +23 -0
- package/errors/base-error.test.js +32 -0
- package/errors/bump.txt +1 -0
- package/errors/bump3.txt +0 -0
- package/errors/fetch-error.js +76 -0
- package/errors/fetch-error.test.js +79 -0
- package/errors/halt-error.js +10 -0
- package/errors/halt-error.test.js +11 -0
- package/errors/index.js +15 -0
- package/errors/jest.config.js +5 -0
- package/errors/validation-errors.js +23 -0
- package/errors/validation-errors.test.js +120 -0
- package/index.js +123 -5
- package/integrations/.eslintrc.json +3 -0
- package/integrations/CHANGELOG.md +244 -0
- package/integrations/LICENSE.md +9 -0
- package/integrations/README.md +3 -0
- package/integrations/bump3.txt +0 -0
- package/integrations/create-frigg-backend.js +31 -0
- package/integrations/index.js +19 -0
- package/integrations/integration-base.js +162 -0
- package/integrations/integration-factory.js +166 -0
- package/integrations/integration-mapping.js +43 -0
- package/integrations/integration-model.js +42 -0
- package/integrations/integration-router.js +367 -0
- package/integrations/integration-user.js +144 -0
- package/integrations/jest-setup.js +2 -0
- package/integrations/jest-teardown.js +2 -0
- package/integrations/jest.config.js +12 -0
- package/integrations/options.js +54 -0
- package/integrations/test/integration-base.test.js +143 -0
- package/lambda/README.md +3 -0
- package/lambda/TimeoutCatcher.js +43 -0
- package/lambda/TimeoutCatcher.test.js +68 -0
- package/lambda/bump3.txt +0 -0
- package/lambda/index.js +3 -0
- package/lambda/jest.config.js +3 -0
- package/logs/.eslintrc.json +3 -0
- package/logs/CHANGELOG.md +57 -0
- package/logs/LICENSE.md +9 -0
- package/logs/README.md +3 -0
- package/logs/bump3.txt +0 -0
- package/logs/index.js +7 -0
- package/logs/jest.config.js +5 -0
- package/logs/logger.js +69 -0
- package/logs/logger.test.js +76 -0
- package/module-plugin/.eslintrc.json +3 -0
- package/module-plugin/CHANGELOG.md +224 -0
- package/module-plugin/LICENSE.md +9 -0
- package/module-plugin/ModuleConstants.js +10 -0
- package/module-plugin/README.md +3 -0
- package/module-plugin/auther.js +342 -0
- package/module-plugin/bump3.txt +0 -0
- package/module-plugin/credential.js +22 -0
- package/module-plugin/entity-manager.js +70 -0
- package/module-plugin/entity.js +46 -0
- package/module-plugin/index.js +25 -0
- package/module-plugin/jest-setup.js +3 -0
- package/module-plugin/jest-teardown.js +2 -0
- package/module-plugin/jest.config.js +20 -0
- package/module-plugin/manager.js +169 -0
- package/module-plugin/module-factory.js +60 -0
- package/module-plugin/requester/api-key.js +36 -0
- package/module-plugin/requester/basic.js +43 -0
- package/module-plugin/requester/oauth-2.js +219 -0
- package/module-plugin/requester/requester.js +151 -0
- package/module-plugin/requester/requester.test.js +28 -0
- package/module-plugin/test/auther.test.js +97 -0
- package/module-plugin/test/mock-api/api.js +29 -0
- package/module-plugin/test/mock-api/definition.js +48 -0
- package/module-plugin/test/mock-api/mocks/hubspot.js +43 -0
- package/package.json +28 -12
- package/syncs/README.md +3 -0
- package/syncs/bump3.txt +0 -0
- package/syncs/jest.config.js +5 -0
- package/syncs/manager.js +464 -0
- package/syncs/model.js +62 -0
- package/syncs/sync.js +114 -0
- package/types/CHANGELOG.md +49 -0
- package/types/README.md +24 -0
- package/types/assertions/index.d.ts +83 -0
- package/types/associations/index.d.ts +74 -0
- package/types/bump3.txt +0 -0
- package/types/core/index.d.ts +54 -0
- package/types/database/index.d.ts +3 -0
- package/types/encrypt/index.d.ts +5 -0
- package/types/errors/index.d.ts +66 -0
- package/types/eslint-config/index.d.ts +41 -0
- package/types/index.d.ts +14 -0
- package/types/integrations/index.d.ts +191 -0
- package/types/lambda/index.d.ts +31 -0
- package/types/logs/index.d.ts +5 -0
- package/types/module-plugin/index.d.ts +293 -0
- package/types/prettier-config/index.d.ts +6 -0
- package/types/syncs/index.d.ts +128 -0
- package/types/test-environment/index.d.ts +17 -0
- package/types/tsconfig.json +103 -0
- /package/{.eslintrc.json → assertions/.eslintrc.json} +0 -0
- /package/{bump3.txt → assertions/bump3.txt} +0 -0
- /package/{jest.config.js → assertions/jest.config.js} +0 -0
- /package/{CHANGELOG.md → core/CHANGELOG.md} +0 -0
- /package/{README.md → core/README.md} +0 -0
- /package/{load-installed-modules.js → core/load-installed-modules.js} +0 -0
package/types/README.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# types
|
|
2
|
+
|
|
3
|
+
This package exports the `types` used in [Frigg](https://friggframework.org) packages.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Get Started
|
|
7
|
+
Install the package with `npm` or `yarn`:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @friggframework/types
|
|
11
|
+
```
|
|
12
|
+
or
|
|
13
|
+
```bash
|
|
14
|
+
yarn add @friggframework/types
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Make sure to reference the types in your `tsconfig.json`
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
"typeRoots": [
|
|
21
|
+
"./node_modules/@types",
|
|
22
|
+
"./node_modules/@friggframework/types"
|
|
23
|
+
]
|
|
24
|
+
```
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
declare module "@friggframework/assertions" {
|
|
2
|
+
type TypeOfType =
|
|
3
|
+
| "undefined"
|
|
4
|
+
| "object"
|
|
5
|
+
| "boolean"
|
|
6
|
+
| "number"
|
|
7
|
+
| "string"
|
|
8
|
+
| "function"
|
|
9
|
+
| "symbol"
|
|
10
|
+
| "bigint";
|
|
11
|
+
|
|
12
|
+
export function get<TObject extends object, TKey extends string, TDefault>(
|
|
13
|
+
object: TObject,
|
|
14
|
+
key: TKey | undefined,
|
|
15
|
+
defaultValue: Exclude<TDefault, undefined>
|
|
16
|
+
): TKey extends keyof TObject ? TObject[TKey] : TDefault;
|
|
17
|
+
|
|
18
|
+
export function get<TObject extends object, TKey extends keyof TObject>(
|
|
19
|
+
object: TObject,
|
|
20
|
+
key: TKey
|
|
21
|
+
): TObject[TKey];
|
|
22
|
+
|
|
23
|
+
export function getAll<TObject extends object, TKey extends keyof TObject>(
|
|
24
|
+
object: TObject,
|
|
25
|
+
requiredKeys: TKey[]
|
|
26
|
+
): Partial<TObject>;
|
|
27
|
+
|
|
28
|
+
export function verifyType(value: unknown, paramType: TypeOfType): void;
|
|
29
|
+
|
|
30
|
+
export function getParamAndVerifyParamType<
|
|
31
|
+
TObject extends object,
|
|
32
|
+
TKey extends string,
|
|
33
|
+
TKeyType extends TypeOfType,
|
|
34
|
+
TDefault
|
|
35
|
+
>(
|
|
36
|
+
params: TObject,
|
|
37
|
+
key: TKey,
|
|
38
|
+
type: TKeyType,
|
|
39
|
+
defaultValue: TDefault
|
|
40
|
+
): TDefault;
|
|
41
|
+
|
|
42
|
+
export function getParamAndVerifyParamType<
|
|
43
|
+
TObject extends object,
|
|
44
|
+
TKey extends keyof TObject,
|
|
45
|
+
TKeyType extends TypeOfType
|
|
46
|
+
>(params: TObject, key: TKey, type: TKeyType): TObject[TKey];
|
|
47
|
+
|
|
48
|
+
export function getArrayParamAndVerifyParamType<
|
|
49
|
+
TObject extends object,
|
|
50
|
+
TKey extends string,
|
|
51
|
+
TKeyType extends TypeOfType,
|
|
52
|
+
TDefault
|
|
53
|
+
>(
|
|
54
|
+
params: TObject,
|
|
55
|
+
key: TKey,
|
|
56
|
+
type: TKeyType,
|
|
57
|
+
defaultValue: TDefault
|
|
58
|
+
): TDefault;
|
|
59
|
+
|
|
60
|
+
export function getArrayParamAndVerifyParamType<
|
|
61
|
+
TObject extends object,
|
|
62
|
+
TKey extends keyof TObject,
|
|
63
|
+
TKeyType extends TypeOfType
|
|
64
|
+
>(params: TObject, key: TKey, type: TKeyType): TObject[TKey];
|
|
65
|
+
|
|
66
|
+
export function getAndVerifyType<
|
|
67
|
+
TObject extends object,
|
|
68
|
+
TKey extends keyof TObject,
|
|
69
|
+
TClassType extends unknown
|
|
70
|
+
>(object: TObject, key: TKey, classType: TClassType): TObject[TKey];
|
|
71
|
+
|
|
72
|
+
export function getAndVerifyType<
|
|
73
|
+
TObject extends object,
|
|
74
|
+
TKey extends string,
|
|
75
|
+
TClassType extends unknown,
|
|
76
|
+
TDefault
|
|
77
|
+
>(
|
|
78
|
+
object: TObject,
|
|
79
|
+
key: TKey,
|
|
80
|
+
classType: TClassType,
|
|
81
|
+
defaultValue: TDefault
|
|
82
|
+
): TKey extends keyof TObject ? TObject[TKey] : TDefault;
|
|
83
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
declare module "@friggframework/associations/model" {
|
|
2
|
+
import { Model } from "mongoose";
|
|
3
|
+
|
|
4
|
+
export class Association extends Model {
|
|
5
|
+
integrationId: string;
|
|
6
|
+
name: string;
|
|
7
|
+
type: string;
|
|
8
|
+
primaryObject: string;
|
|
9
|
+
objects: {
|
|
10
|
+
entityId: string;
|
|
11
|
+
objectType: string;
|
|
12
|
+
objId: string;
|
|
13
|
+
metadata?: object;
|
|
14
|
+
}[];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare module "@friggframework/associations/association" {
|
|
19
|
+
export default class Association implements IFriggAssociation {
|
|
20
|
+
data: any;
|
|
21
|
+
dataIdentifier: any;
|
|
22
|
+
dataIdentifierHash: string;
|
|
23
|
+
matchHash: string;
|
|
24
|
+
moduleName: any;
|
|
25
|
+
syncId: any;
|
|
26
|
+
|
|
27
|
+
static Config: {
|
|
28
|
+
name: "Association";
|
|
29
|
+
reverseModuleMap: {};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
constructor(params: AssociationConstructor);
|
|
33
|
+
|
|
34
|
+
dataKeyIsReplaceable(key: string): boolean;
|
|
35
|
+
|
|
36
|
+
equals(syncObj: any): boolean;
|
|
37
|
+
|
|
38
|
+
getHashData(): string;
|
|
39
|
+
|
|
40
|
+
getName(): any;
|
|
41
|
+
|
|
42
|
+
hashJSON(data: any): string;
|
|
43
|
+
|
|
44
|
+
isModuleInMap(moduleName: any): any;
|
|
45
|
+
|
|
46
|
+
reverseModuleMap(moduleName: any): any;
|
|
47
|
+
|
|
48
|
+
setSyncId(syncId: string): any;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface IFriggAssociation {
|
|
52
|
+
data: any;
|
|
53
|
+
moduleName: any;
|
|
54
|
+
dataIdentifier: any;
|
|
55
|
+
dataIdentifierHash: string;
|
|
56
|
+
matchHash: string;
|
|
57
|
+
syncId: any;
|
|
58
|
+
|
|
59
|
+
equals(syncObj: any): boolean;
|
|
60
|
+
dataKeyIsReplaceable(key: string): boolean;
|
|
61
|
+
isModuleInMap(moduleName: any): any;
|
|
62
|
+
getName(): any;
|
|
63
|
+
getHashData(): string;
|
|
64
|
+
setSyncId(syncId: string): any;
|
|
65
|
+
reverseModuleMap(moduleName: any): any;
|
|
66
|
+
hashJSON(data: any): string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
type AssociationConstructor = {
|
|
70
|
+
data: any;
|
|
71
|
+
moduleName: any;
|
|
72
|
+
dataIdentifier: any;
|
|
73
|
+
};
|
|
74
|
+
}
|
package/types/bump3.txt
ADDED
|
File without changes
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
declare module "@friggframework/core" {
|
|
2
|
+
import { SQS } from "aws-sdk";
|
|
3
|
+
|
|
4
|
+
export class Delegate implements IFriggDelegate {
|
|
5
|
+
delegate: any;
|
|
6
|
+
delegateTypes: any[];
|
|
7
|
+
|
|
8
|
+
constructor(params: Record<string, unknown> & { delegate?: unknown });
|
|
9
|
+
notify(delegateString: string, object?: any): Promise<any>;
|
|
10
|
+
receiveNotification(
|
|
11
|
+
notifier: any,
|
|
12
|
+
delegateString: string,
|
|
13
|
+
object?: any
|
|
14
|
+
): Promise<any>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface IFriggDelegate {
|
|
18
|
+
delegate: any;
|
|
19
|
+
delegateTypes: any[];
|
|
20
|
+
|
|
21
|
+
notify(delegateString: string, object?: any): Promise<any>;
|
|
22
|
+
receiveNotification(
|
|
23
|
+
notifier: any,
|
|
24
|
+
delegateString: string,
|
|
25
|
+
object?: any
|
|
26
|
+
): Promise<any>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class Worker implements IWorker {
|
|
30
|
+
getQueueURL(params: GetQueueURLParams): Promise<string | undefined>;
|
|
31
|
+
|
|
32
|
+
run(params: { Records: any }): Promise<void>;
|
|
33
|
+
|
|
34
|
+
send(params: object & { QueueUrl: any }, delay?: number): Promise<string>;
|
|
35
|
+
|
|
36
|
+
sendAsyncSQSMessage(params: SendSQSMessageParams): Promise<string>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
interface IWorker {
|
|
40
|
+
getQueueURL(params: GetQueueURLParams): Promise<string | undefined>;
|
|
41
|
+
run(params: { Records: any }): Promise<void>;
|
|
42
|
+
send(params: object & { QueueUrl: any }, delay?: number): Promise<string>;
|
|
43
|
+
sendAsyncSQSMessage(params: SendSQSMessageParams): Promise<string>;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function loadInstalledModules(): any[];
|
|
47
|
+
|
|
48
|
+
type GetQueueURLParams = {
|
|
49
|
+
QueueName: string;
|
|
50
|
+
QueueOwnerAWSAccountId?: string;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
type SendSQSMessageParams = SQS.SendMessageRequest;
|
|
54
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
declare module "@friggframework/errors" {
|
|
2
|
+
export class BaseError extends Error {
|
|
3
|
+
constructor(message?: string, options?: ErrorOptions, ...otherOptions: any);
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export class FetchError extends BaseError {
|
|
7
|
+
constructor(options?: FetchErrorConstructor);
|
|
8
|
+
|
|
9
|
+
static create(options?: CreateFetchErrorParams): Promise<FetchError>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type FetchErrorConstructor = {
|
|
13
|
+
resource?: string;
|
|
14
|
+
init?: Partial<{
|
|
15
|
+
method: string;
|
|
16
|
+
credentials: string;
|
|
17
|
+
headers: object;
|
|
18
|
+
query: object;
|
|
19
|
+
body: URLSearchParams | any;
|
|
20
|
+
returnFullRes: false;
|
|
21
|
+
}>;
|
|
22
|
+
response?: {
|
|
23
|
+
headers?: object;
|
|
24
|
+
status?: number;
|
|
25
|
+
statusText?: string;
|
|
26
|
+
text?: () => Promise<string>;
|
|
27
|
+
};
|
|
28
|
+
responseBody?: any;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type CreateFetchErrorParams = Omit<FetchErrorConstructor, "responseBody"> & {
|
|
32
|
+
body: any;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export class HaltError extends BaseError {
|
|
36
|
+
isHaltError: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export class RequiredPropertyError extends BaseError {
|
|
40
|
+
constructor(
|
|
41
|
+
options: RequiredPropertyErrorOptions,
|
|
42
|
+
otherOptions?: ErrorOptions
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
type RequiredPropertyErrorOptions = {
|
|
47
|
+
parent?: new () => Class;
|
|
48
|
+
key: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export class ParameterTypeError extends BaseError {
|
|
52
|
+
constructor(
|
|
53
|
+
options: ParameterTypeErrorOptions,
|
|
54
|
+
otherOptions?: ErrorOptions
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
type ParameterTypeErrorOptions = {
|
|
59
|
+
parent?: new () => Class;
|
|
60
|
+
key: string;
|
|
61
|
+
value: string;
|
|
62
|
+
expectedType: new () => Class;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
type Class<T = any> = new (...args: any[]) => T;
|
|
66
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
declare module "@friggframework/eslint-config" {
|
|
2
|
+
const config: {
|
|
3
|
+
env: {
|
|
4
|
+
commonjs: true,
|
|
5
|
+
es2020: true,
|
|
6
|
+
jest: true,
|
|
7
|
+
},
|
|
8
|
+
extends: ["prettier", "plugin:markdown/recommended"],
|
|
9
|
+
parser: "@babel/eslint-parser",
|
|
10
|
+
parserOptions: {
|
|
11
|
+
ecmaVersion: 11,
|
|
12
|
+
requireConfigFile: false,
|
|
13
|
+
},
|
|
14
|
+
plugins: ["no-only-tests"],
|
|
15
|
+
ignorePatterns: ["coverage/", ".nyc_output/"],
|
|
16
|
+
overrides: [
|
|
17
|
+
{
|
|
18
|
+
files: ["*.json"],
|
|
19
|
+
plugins: ["json"],
|
|
20
|
+
extends: ["plugin:json/recommended"],
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
files: ["*.yaml", "*.yml"],
|
|
24
|
+
plugins: ["yaml"],
|
|
25
|
+
extends: ["plugin:yaml/recommended"],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
rules: {
|
|
29
|
+
"no-only-tests/no-only-tests": ["error", { fix: false }],
|
|
30
|
+
"no-unused-vars": [
|
|
31
|
+
"warn",
|
|
32
|
+
{ vars: "all", args: "after-used", ignoreRestSiblings: false },
|
|
33
|
+
],
|
|
34
|
+
"no-console": ["warn"],
|
|
35
|
+
camelcase: ["warn"],
|
|
36
|
+
"no-mixed-requires": ["warn"],
|
|
37
|
+
"no-warning-comments": ["warn"],
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
export default config;
|
|
41
|
+
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference path="./assertions/index.d.ts" />
|
|
2
|
+
/// <reference path="./core/index.d.ts" />
|
|
3
|
+
/// <reference path="./integrations/index.d.ts" />
|
|
4
|
+
/// <reference path="./encrypt/index.d.ts" />
|
|
5
|
+
/// <reference path="./errors/index.d.ts" />
|
|
6
|
+
/// <reference path="./module-plugin/index.d.ts" />
|
|
7
|
+
/// <reference path="./database/index.d.ts" />
|
|
8
|
+
/// <reference path="./lambda/index.d.ts" />
|
|
9
|
+
/// <reference path="./logs/index.d.ts" />
|
|
10
|
+
/// <reference path="./test-environment/index.d.ts" />
|
|
11
|
+
/// <reference path="./prettier-config/index.d.ts" />
|
|
12
|
+
/// <reference path="./eslint-config/index.d.ts" />
|
|
13
|
+
/// <reference path="./associations/index.d.ts" />
|
|
14
|
+
/// <reference path="./syncs/index.d.ts" />
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
declare module "@friggframework/integrations" {
|
|
2
|
+
import { Delegate, IFriggDelegate } from "@friggframework/core";
|
|
3
|
+
import { Model } from "mongoose";
|
|
4
|
+
import { EntityManager } from "@friggframework/module-plugin";
|
|
5
|
+
|
|
6
|
+
export class Integration extends Model {
|
|
7
|
+
entities: any[];
|
|
8
|
+
userId: string;
|
|
9
|
+
status: string; // IntegrationStatus
|
|
10
|
+
config: any;
|
|
11
|
+
version: string;
|
|
12
|
+
messages: {
|
|
13
|
+
errors: [];
|
|
14
|
+
warnings: [];
|
|
15
|
+
info: [];
|
|
16
|
+
logs: [];
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class IntegrationManager
|
|
21
|
+
extends Delegate
|
|
22
|
+
implements IFriggIntegrationManager
|
|
23
|
+
{
|
|
24
|
+
integration: Integration;
|
|
25
|
+
primaryInstance: any;
|
|
26
|
+
targetInstance: any;
|
|
27
|
+
|
|
28
|
+
static Config: {
|
|
29
|
+
name: string;
|
|
30
|
+
version: string;
|
|
31
|
+
supportedVersions: string[];
|
|
32
|
+
events: string[];
|
|
33
|
+
};
|
|
34
|
+
static integrationManagerClasses: any[];
|
|
35
|
+
static integrationTypes: string[];
|
|
36
|
+
|
|
37
|
+
constructor(params: any);
|
|
38
|
+
|
|
39
|
+
static getInstanceFromIntegrationId(params: {
|
|
40
|
+
integrationId: string;
|
|
41
|
+
userId?: string;
|
|
42
|
+
}): Promise<any>;
|
|
43
|
+
static getName(): string;
|
|
44
|
+
static getCurrentVersion(): string;
|
|
45
|
+
|
|
46
|
+
validateConfig(): Promise<void>;
|
|
47
|
+
testAuth(): Promise<void>;
|
|
48
|
+
|
|
49
|
+
static getInstance(params: {
|
|
50
|
+
userId: string;
|
|
51
|
+
integrationId: string;
|
|
52
|
+
}): Promise<IntegrationManager>;
|
|
53
|
+
static getIntegrationManagerClasses(type: string): any[];
|
|
54
|
+
|
|
55
|
+
static createIntegration(
|
|
56
|
+
entities: { id: string; user: any },
|
|
57
|
+
userId: string,
|
|
58
|
+
config: any,
|
|
59
|
+
EntityManager: EntityManager
|
|
60
|
+
): Promise<any>;
|
|
61
|
+
|
|
62
|
+
static getFormattedIntegration(
|
|
63
|
+
integration: Integration
|
|
64
|
+
): Promise<FormattedIntegration[]>;
|
|
65
|
+
static getIntegrationsForUserId(
|
|
66
|
+
userId: string
|
|
67
|
+
): Promise<FormattedIntegration[]>;
|
|
68
|
+
static getIntegrationForUserById(
|
|
69
|
+
userId: string,
|
|
70
|
+
integrationId: string
|
|
71
|
+
): Promise<Integration>;
|
|
72
|
+
static deleteIntegrationForUserById(
|
|
73
|
+
userId: string,
|
|
74
|
+
integrationId: string
|
|
75
|
+
): Promise<void>;
|
|
76
|
+
static getIntegrationById(id: string): Promise<Integration>;
|
|
77
|
+
static getFilteredIntegrationsForUserId(
|
|
78
|
+
userId: string,
|
|
79
|
+
filter: any
|
|
80
|
+
): Promise<Integration[]>;
|
|
81
|
+
static getCredentialById(credential_id: string): Promise<any>;
|
|
82
|
+
static listCredentials(options: any): Promise<any>;
|
|
83
|
+
static getEntityById(entity_id: any): Promise<any>;
|
|
84
|
+
static listEntities(options: any): Promise<any>;
|
|
85
|
+
|
|
86
|
+
processCreate(params: any): Promise<any>;
|
|
87
|
+
processUpdate(params: any): Promise<any>;
|
|
88
|
+
processDelete(params: any): Promise<any>;
|
|
89
|
+
|
|
90
|
+
getConfigOptions(): Promise<any>;
|
|
91
|
+
getSampleData(): Promise<any>;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
type FormattedIntegration = {
|
|
95
|
+
entities: any[];
|
|
96
|
+
messages: any;
|
|
97
|
+
id: any;
|
|
98
|
+
config: any;
|
|
99
|
+
version: any;
|
|
100
|
+
status: any;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
interface IFriggIntegrationManager extends IFriggDelegate {
|
|
104
|
+
primaryInstance: any; // Returns the Freshbooks manager instance
|
|
105
|
+
targetInstance: any; // Returns a manager e.g. StripeManager instance containing the entitiy, credential, api etc
|
|
106
|
+
integration: Integration; // Integration model instance
|
|
107
|
+
|
|
108
|
+
validateConfig(): Promise<void>;
|
|
109
|
+
testAuth(): Promise<void>;
|
|
110
|
+
processCreate(params: any): Promise<any>;
|
|
111
|
+
processUpdate(params: any): Promise<any>;
|
|
112
|
+
processDelete(params: any): Promise<any>;
|
|
113
|
+
|
|
114
|
+
getConfigOptions(): Promise<any>;
|
|
115
|
+
getSampleData(): Promise<any>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export class IntegrationConfigManager
|
|
119
|
+
implements IFriggIntegrationConfigManager
|
|
120
|
+
{
|
|
121
|
+
options: IntegrationOptions[];
|
|
122
|
+
primary: any;
|
|
123
|
+
|
|
124
|
+
getIntegrationOptions(): Promise<GetIntegrationOptions>;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
interface IFriggIntegrationConfigManager {
|
|
128
|
+
options: IntegrationOptions[];
|
|
129
|
+
primary: any;
|
|
130
|
+
|
|
131
|
+
getIntegrationOptions(): Promise<GetIntegrationOptions>;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
type GetIntegrationOptions = {
|
|
135
|
+
entities: {
|
|
136
|
+
primary: any;
|
|
137
|
+
options: any[];
|
|
138
|
+
autorized: any[];
|
|
139
|
+
};
|
|
140
|
+
integrations: any[];
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
export class Options implements IFriggIntegrationOptions {
|
|
144
|
+
display: IntegrationOptionDisplay;
|
|
145
|
+
hasUserConfig: boolean;
|
|
146
|
+
isMany: boolean;
|
|
147
|
+
module: any;
|
|
148
|
+
requiresNewEntity: boolean;
|
|
149
|
+
type: string;
|
|
150
|
+
|
|
151
|
+
constructor(params: {
|
|
152
|
+
display: Partial<IntegrationOptionDisplay>;
|
|
153
|
+
type?: string;
|
|
154
|
+
hasUserConfig?: boolean;
|
|
155
|
+
isMany?: boolean;
|
|
156
|
+
requiresNewEntity?: boolean;
|
|
157
|
+
module?: any;
|
|
158
|
+
});
|
|
159
|
+
get(): IntegrationOptions;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
interface IFriggIntegrationOptions {
|
|
163
|
+
module: any;
|
|
164
|
+
type: string;
|
|
165
|
+
hasUserConfig: boolean;
|
|
166
|
+
isMany: boolean;
|
|
167
|
+
requiresNewEntity: boolean;
|
|
168
|
+
display: IntegrationOptionDisplay;
|
|
169
|
+
|
|
170
|
+
get(): IntegrationOptions;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
type IntegrationOptions = {
|
|
174
|
+
type: string;
|
|
175
|
+
hasUserConfig: boolean;
|
|
176
|
+
isMany: boolean;
|
|
177
|
+
requiresNewEntity: boolean;
|
|
178
|
+
display: IntegrationOptionDisplay;
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
type IntegrationOptionDisplay = {
|
|
182
|
+
name: string;
|
|
183
|
+
description: string;
|
|
184
|
+
detailsUrl: string;
|
|
185
|
+
icon: string;
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
interface IFriggIntegrationsPackage {
|
|
189
|
+
IntegrationManager: IFriggIntegrationManager;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare module "@friggframework/lambda/TimeoutCatcher" {
|
|
2
|
+
export class TimeoutCatcher implements IFriggTimeoutCatcher {
|
|
3
|
+
isFinished: boolean;
|
|
4
|
+
waitTime: number;
|
|
5
|
+
|
|
6
|
+
constructor(params: TimeoutCatcherConstructor);
|
|
7
|
+
work(): Promise<any>;
|
|
8
|
+
cleanUp(): Promise<any>;
|
|
9
|
+
doWork(): Promise<void>;
|
|
10
|
+
exitBeforeTimeout(): Promise<void>;
|
|
11
|
+
watch(): Promise<boolean>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface IFriggTimeoutCatcher {
|
|
15
|
+
isFinished: boolean;
|
|
16
|
+
work: () => Promise<any>;
|
|
17
|
+
cleanUp: () => Promise<any>;
|
|
18
|
+
waitTime: number;
|
|
19
|
+
|
|
20
|
+
watch(): Promise<boolean>;
|
|
21
|
+
doWork(): Promise<void>;
|
|
22
|
+
exitBeforeTimeout(): Promise<void>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
type TimeoutCatcherConstructor = {
|
|
26
|
+
work: () => Promise<any>;
|
|
27
|
+
timeout: number;
|
|
28
|
+
cleanUp?: () => Promise<any>;
|
|
29
|
+
cleanUpTime?: number;
|
|
30
|
+
};
|
|
31
|
+
}
|