@friggframework/core 2.0.0--canary.522.cbd3d5a.0 → 2.0.0--canary.517.35ee143.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.
Files changed (225) hide show
  1. package/CHANGELOG.md +67 -66
  2. package/CLAUDE.md +124 -148
  3. package/README.md +130 -165
  4. package/admin-scripts/index.js +16 -30
  5. package/admin-scripts/repositories/{admin-api-key-repository-documentdb.js → admin-process-repository-documentdb.js} +5 -5
  6. package/admin-scripts/repositories/{admin-api-key-repository-factory.js → admin-process-repository-factory.js} +15 -19
  7. package/admin-scripts/repositories/admin-process-repository-interface.js +150 -0
  8. package/admin-scripts/repositories/admin-process-repository-mongo.js +213 -0
  9. package/admin-scripts/repositories/admin-process-repository-postgres.js +251 -0
  10. package/admin-scripts/repositories/script-schedule-repository-factory.js +2 -6
  11. package/admin-scripts/repositories/script-schedule-repository-interface.js +14 -36
  12. package/admin-scripts/repositories/script-schedule-repository-mongo.js +13 -25
  13. package/admin-scripts/repositories/script-schedule-repository-postgres.js +13 -25
  14. package/application/commands/admin-script-commands.js +102 -266
  15. package/application/commands/integration-commands.js +6 -12
  16. package/application/index.js +3 -1
  17. package/assertions/get.js +4 -1
  18. package/associations/association.js +57 -59
  19. package/associations/model.js +41 -41
  20. package/core/CLAUDE.md +156 -222
  21. package/core/Worker.js +1 -5
  22. package/credential/repositories/credential-repository-documentdb.js +1 -71
  23. package/credential/repositories/credential-repository-interface.js +2 -8
  24. package/credential/repositories/credential-repository-mongo.js +4 -45
  25. package/credential/repositories/credential-repository-postgres.js +3 -44
  26. package/credential/repositories/credential-repository.js +4 -6
  27. package/credential/use-cases/get-credential-for-user.js +3 -21
  28. package/credential/use-cases/update-authentication-status.js +2 -5
  29. package/database/MONGODB_TRANSACTION_FIX.md +52 -72
  30. package/database/adapters/lambda-invoker.js +7 -8
  31. package/database/config.js +13 -15
  32. package/database/documentdb-encryption-service.js +13 -29
  33. package/database/documentdb-utils.js +12 -21
  34. package/database/encryption/README.md +36 -53
  35. package/database/encryption/encryption-schema-registry.js +9 -21
  36. package/database/encryption/field-encryption-service.js +4 -15
  37. package/database/encryption/logger.js +2 -3
  38. package/database/encryption/prisma-encryption-extension.js +8 -5
  39. package/database/index.js +2 -4
  40. package/database/models/IndividualUser.js +15 -15
  41. package/database/models/OrganizationUser.js +4 -6
  42. package/database/models/UserModel.js +2 -2
  43. package/database/models/WebsocketConnection.js +1 -4
  44. package/database/mongoose.js +2 -2
  45. package/database/prisma.js +14 -22
  46. package/database/repositories/health-check-repository-documentdb.js +7 -22
  47. package/database/repositories/health-check-repository-factory.js +3 -9
  48. package/database/repositories/health-check-repository-interface.js +5 -15
  49. package/database/repositories/health-check-repository-mongodb.js +6 -9
  50. package/database/repositories/health-check-repository-postgres.js +1 -1
  51. package/database/repositories/migration-status-repository-s3.js +5 -10
  52. package/database/use-cases/check-database-health-use-case.js +2 -3
  53. package/database/use-cases/check-database-state-use-case.js +7 -9
  54. package/database/use-cases/get-database-state-via-worker-use-case.js +12 -15
  55. package/database/use-cases/get-migration-status-use-case.js +2 -4
  56. package/database/use-cases/run-database-migration-use-case.js +9 -41
  57. package/database/use-cases/test-encryption-use-case.js +5 -4
  58. package/database/use-cases/trigger-database-migration-use-case.js +8 -9
  59. package/database/utils/mongodb-collection-utils.js +3 -11
  60. package/database/utils/mongodb-schema-init.js +4 -10
  61. package/database/utils/prisma-runner.js +74 -144
  62. package/database/utils/prisma-schema-parser.js +2 -2
  63. package/docs/PROCESS_MANAGEMENT_QUEUE_SPEC.md +80 -135
  64. package/encrypt/Cryptor.js +2 -8
  65. package/errors/fetch-error.js +1 -1
  66. package/generated/prisma-mongodb/edge.js +16 -59
  67. package/generated/prisma-mongodb/index-browser.js +12 -62
  68. package/generated/prisma-mongodb/index.d.ts +4850 -8136
  69. package/generated/prisma-mongodb/index.js +16 -59
  70. package/generated/prisma-mongodb/package.json +1 -1
  71. package/generated/prisma-mongodb/schema.prisma +33 -75
  72. package/generated/prisma-mongodb/wasm.js +16 -59
  73. package/generated/prisma-postgresql/edge.js +15 -59
  74. package/generated/prisma-postgresql/index-browser.js +11 -62
  75. package/generated/prisma-postgresql/index.d.ts +5963 -8930
  76. package/generated/prisma-postgresql/index.js +15 -59
  77. package/generated/prisma-postgresql/package.json +1 -1
  78. package/generated/prisma-postgresql/schema.prisma +33 -73
  79. package/generated/prisma-postgresql/wasm.js +15 -59
  80. package/handlers/WEBHOOKS.md +81 -104
  81. package/handlers/app-definition-loader.js +1 -1
  82. package/handlers/app-handler-helpers.js +2 -14
  83. package/handlers/backend-utils.js +1 -0
  84. package/handlers/database-migration-handler.js +45 -64
  85. package/handlers/middleware/admin-auth.js +53 -0
  86. package/handlers/routers/HEALTHCHECK.md +135 -170
  87. package/handlers/routers/auth.js +2 -23
  88. package/handlers/routers/db-migration.handler.js +3 -2
  89. package/handlers/routers/db-migration.js +33 -69
  90. package/handlers/routers/health.js +8 -23
  91. package/handlers/routers/integration-defined-routers.js +4 -4
  92. package/handlers/routers/integration-webhook-routers.js +7 -17
  93. package/handlers/routers/websocket.js +3 -9
  94. package/handlers/use-cases/check-integrations-health-use-case.js +6 -13
  95. package/handlers/workers/db-migration.js +26 -54
  96. package/index.js +9 -5
  97. package/integrations/WEBHOOK-QUICKSTART.md +14 -21
  98. package/integrations/index.js +0 -4
  99. package/integrations/integration-base.js +6 -9
  100. package/integrations/integration-router.js +146 -1817
  101. package/integrations/options.js +20 -47
  102. package/integrations/repositories/integration-repository-documentdb.js +24 -53
  103. package/integrations/repositories/integration-repository-factory.js +2 -6
  104. package/integrations/repositories/integration-repository-interface.js +9 -27
  105. package/integrations/repositories/integration-repository-postgres.js +3 -3
  106. package/integrations/repositories/process-repository-factory.js +1 -0
  107. package/integrations/repositories/process-repository-interface.js +5 -9
  108. package/integrations/repositories/process-repository-mongo.js +3 -7
  109. package/integrations/repositories/process-repository-postgres.js +2 -2
  110. package/integrations/tests/doubles/config-capturing-integration.js +8 -9
  111. package/integrations/tests/doubles/dummy-integration-class.js +8 -81
  112. package/integrations/tests/doubles/test-integration-repository.js +11 -51
  113. package/integrations/use-cases/create-integration.js +32 -36
  114. package/integrations/use-cases/create-process.js +9 -20
  115. package/integrations/use-cases/delete-integration-for-user.js +4 -5
  116. package/integrations/use-cases/get-integration-for-user.js +10 -25
  117. package/integrations/use-cases/get-integration-instance-by-definition.js +7 -13
  118. package/integrations/use-cases/get-integrations-for-user.js +1 -4
  119. package/integrations/use-cases/get-possible-integrations.js +1 -1
  120. package/integrations/use-cases/get-process.js +6 -5
  121. package/integrations/use-cases/index.js +1 -3
  122. package/integrations/use-cases/load-integration-context.js +5 -1
  123. package/integrations/use-cases/update-process-state.js +8 -10
  124. package/integrations/utils/map-integration-dto.js +3 -9
  125. package/jest-setup.js +1 -1
  126. package/jest-teardown.js +1 -1
  127. package/lambda/TimeoutCatcher.js +30 -32
  128. package/lambda/index.js +1 -1
  129. package/logs/index.js +3 -3
  130. package/modules/module.js +1 -3
  131. package/modules/repositories/module-repository-documentdb.js +48 -114
  132. package/modules/repositories/module-repository-interface.js +0 -13
  133. package/modules/repositories/module-repository-mongo.js +6 -46
  134. package/modules/repositories/module-repository-postgres.js +6 -48
  135. package/modules/repositories/module-repository.js +1 -34
  136. package/modules/requester/api-key.js +2 -0
  137. package/modules/requester/basic.js +1 -0
  138. package/modules/requester/oauth-2.js +2 -3
  139. package/modules/test/mock-api/definition.js +10 -15
  140. package/modules/test/mock-api/mocks/hubspot.js +36 -36
  141. package/modules/tests/doubles/test-module-factory.js +4 -10
  142. package/modules/tests/doubles/test-module-repository.js +1 -1
  143. package/modules/use-cases/get-entities-for-user.js +1 -1
  144. package/modules/use-cases/get-entity-options-by-id.js +6 -8
  145. package/modules/use-cases/get-module.js +9 -12
  146. package/modules/use-cases/process-authorization-callback.js +6 -12
  147. package/modules/use-cases/refresh-entity-options.js +6 -8
  148. package/modules/use-cases/test-module-auth.js +6 -8
  149. package/modules/utils/map-module-dto.js +2 -2
  150. package/package.json +5 -7
  151. package/prisma-mongodb/schema.prisma +33 -75
  152. package/prisma-postgresql/schema.prisma +33 -73
  153. package/queues/queuer-util.js +1 -5
  154. package/syncs/model.js +51 -51
  155. package/syncs/repositories/sync-repository-documentdb.js +19 -39
  156. package/syncs/repositories/sync-repository-interface.js +2 -6
  157. package/syncs/repositories/sync-repository-postgres.js +13 -19
  158. package/syncs/sync.js +100 -104
  159. package/token/repositories/token-repository-factory.js +3 -1
  160. package/types/assertions/index.d.ts +72 -72
  161. package/types/associations/index.d.ts +57 -57
  162. package/types/core/index.d.ts +53 -59
  163. package/types/database/index.d.ts +2 -2
  164. package/types/encrypt/index.d.ts +3 -3
  165. package/types/errors/index.d.ts +54 -61
  166. package/types/eslint-config/index.d.ts +40 -40
  167. package/types/integrations/index.d.ts +183 -185
  168. package/types/lambda/index.d.ts +26 -26
  169. package/types/logs/index.d.ts +4 -4
  170. package/types/module-plugin/index.d.ts +237 -239
  171. package/types/prettier-config/index.d.ts +5 -5
  172. package/types/syncs/index.d.ts +108 -102
  173. package/types/test-environment/index.d.ts +14 -14
  174. package/types/tsconfig.json +93 -95
  175. package/user/tests/doubles/test-user-repository.js +2 -5
  176. package/user/use-cases/authenticate-user.js +4 -2
  177. package/user/use-cases/authenticate-with-shared-secret.js +1 -1
  178. package/user/use-cases/create-individual-user.js +7 -8
  179. package/user/use-cases/create-organization-user.js +1 -1
  180. package/user/use-cases/create-token-for-user-id.js +1 -1
  181. package/user/use-cases/get-user-from-adopter-jwt.js +2 -0
  182. package/user/use-cases/get-user-from-bearer-token.js +3 -7
  183. package/user/use-cases/get-user-from-x-frigg-headers.js +11 -14
  184. package/user/use-cases/login-user.js +8 -8
  185. package/user/user.js +4 -18
  186. package/utils/backend-path.js +2 -2
  187. package/utils/index.js +1 -4
  188. package/websocket/repositories/websocket-connection-repository-documentdb.js +8 -21
  189. package/websocket/repositories/websocket-connection-repository-mongo.js +4 -8
  190. package/websocket/repositories/websocket-connection-repository-postgres.js +4 -8
  191. package/websocket/repositories/websocket-connection-repository.js +4 -8
  192. package/admin-scripts/repositories/admin-api-key-repository-interface.js +0 -121
  193. package/admin-scripts/repositories/admin-api-key-repository-mongo.js +0 -155
  194. package/admin-scripts/repositories/admin-api-key-repository-postgres.js +0 -189
  195. package/admin-scripts/repositories/script-execution-repository-documentdb.js +0 -21
  196. package/admin-scripts/repositories/script-execution-repository-factory.js +0 -55
  197. package/admin-scripts/repositories/script-execution-repository-interface.js +0 -193
  198. package/admin-scripts/repositories/script-execution-repository-mongo.js +0 -278
  199. package/admin-scripts/repositories/script-execution-repository-postgres.js +0 -320
  200. package/credential/credential-router.js +0 -262
  201. package/credential/use-cases/delete-credential-for-user.js +0 -50
  202. package/credential/use-cases/list-credentials-for-user.js +0 -31
  203. package/credential/use-cases/reauthorize-credential.js +0 -103
  204. package/handlers/routers/admin.js +0 -450
  205. package/handlers/routers/docs.js +0 -180
  206. package/handlers/routers/middleware/loadUser.js +0 -39
  207. package/handlers/routers/middleware/requireAdmin.js +0 -41
  208. package/handlers/routers/middleware/requireLoggedInUser.js +0 -19
  209. package/integrations/use-cases/execute-proxy-request.js +0 -564
  210. package/modules/domain/entities/AuthorizationSession.js +0 -131
  211. package/modules/domain/entities/index.js +0 -10
  212. package/modules/repositories/authorization-session-repository-factory.js +0 -55
  213. package/modules/repositories/authorization-session-repository-interface.js +0 -75
  214. package/modules/repositories/authorization-session-repository-mongo.js +0 -169
  215. package/modules/repositories/authorization-session-repository-postgres.js +0 -170
  216. package/modules/use-cases/delete-module-entity.js +0 -23
  217. package/modules/use-cases/get-authorization-requirements.js +0 -110
  218. package/modules/use-cases/get-module-entity-by-id.js +0 -16
  219. package/modules/use-cases/process-authorization-step.js +0 -160
  220. package/modules/use-cases/start-authorization-session.js +0 -86
  221. package/modules/use-cases/update-module-entity.js +0 -27
  222. package/openapi/openapi-spec-generator.js +0 -370
  223. package/openapi/openapi-v1.yaml +0 -1360
  224. package/openapi/openapi-v2.yaml +0 -1535
  225. package/user/use-cases/delete-user.js +0 -47
@@ -1,73 +1,66 @@
1
- declare module '@friggframework/errors' {
2
- export class BaseError extends Error {
3
- constructor(
4
- message?: string,
5
- options?: ErrorOptions,
6
- ...otherOptions: any
7
- );
8
- }
1
+ declare module "@friggframework/errors" {
2
+ export class BaseError extends Error {
3
+ constructor(message?: string, options?: ErrorOptions, ...otherOptions: any);
4
+ }
9
5
 
10
- export class FetchError extends BaseError {
11
- constructor(options?: FetchErrorConstructor);
6
+ export class FetchError extends BaseError {
7
+ constructor(options?: FetchErrorConstructor);
12
8
 
13
- static create(options?: CreateFetchErrorParams): Promise<FetchError>;
14
- }
9
+ static create(options?: CreateFetchErrorParams): Promise<FetchError>;
10
+ }
15
11
 
16
- type FetchErrorConstructor = {
17
- resource?: string;
18
- init?: Partial<{
19
- method: string;
20
- credentials: string;
21
- headers: object;
22
- query: object;
23
- body: URLSearchParams | any;
24
- returnFullRes: false;
25
- }>;
26
- response?: {
27
- headers?: object;
28
- status?: number;
29
- statusText?: string;
30
- text?: () => Promise<string>;
31
- };
32
- responseBody?: any;
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>;
33
27
  };
28
+ responseBody?: any;
29
+ };
34
30
 
35
- type CreateFetchErrorParams = Omit<
36
- FetchErrorConstructor,
37
- 'responseBody'
38
- > & {
39
- body: any;
40
- };
31
+ type CreateFetchErrorParams = Omit<FetchErrorConstructor, "responseBody"> & {
32
+ body: any;
33
+ };
41
34
 
42
- export class HaltError extends BaseError {
43
- isHaltError: boolean;
44
- }
35
+ export class HaltError extends BaseError {
36
+ isHaltError: boolean;
37
+ }
45
38
 
46
- export class RequiredPropertyError extends BaseError {
47
- constructor(
48
- options: RequiredPropertyErrorOptions,
49
- otherOptions?: ErrorOptions
50
- );
51
- }
39
+ export class RequiredPropertyError extends BaseError {
40
+ constructor(
41
+ options: RequiredPropertyErrorOptions,
42
+ otherOptions?: ErrorOptions
43
+ );
44
+ }
52
45
 
53
- type RequiredPropertyErrorOptions = {
54
- parent?: new () => Class;
55
- key: string;
56
- };
46
+ type RequiredPropertyErrorOptions = {
47
+ parent?: new () => Class;
48
+ key: string;
49
+ };
57
50
 
58
- export class ParameterTypeError extends BaseError {
59
- constructor(
60
- options: ParameterTypeErrorOptions,
61
- otherOptions?: ErrorOptions
62
- );
63
- }
51
+ export class ParameterTypeError extends BaseError {
52
+ constructor(
53
+ options: ParameterTypeErrorOptions,
54
+ otherOptions?: ErrorOptions
55
+ );
56
+ }
64
57
 
65
- type ParameterTypeErrorOptions = {
66
- parent?: new () => Class;
67
- key: string;
68
- value: string;
69
- expectedType: new () => Class;
70
- };
58
+ type ParameterTypeErrorOptions = {
59
+ parent?: new () => Class;
60
+ key: string;
61
+ value: string;
62
+ expectedType: new () => Class;
63
+ };
71
64
 
72
- type Class<T = any> = new (...args: any[]) => T;
65
+ type Class<T = any> = new (...args: any[]) => T;
73
66
  }
@@ -1,41 +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;
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
41
  }
@@ -1,189 +1,187 @@
1
- declare module '@friggframework/integrations' {
2
- import { Delegate, IFriggDelegate } from '@friggframework/core';
3
- import { Model } from 'mongoose';
4
-
5
- export class Integration extends Model {
6
- entities: any[];
7
- userId: string;
8
- status: string; // IntegrationStatus
9
- config: any;
10
- version: string;
11
- messages: {
12
- errors: [];
13
- warnings: [];
14
- info: [];
15
- logs: [];
16
- };
17
- }
18
-
19
- export class IntegrationManager
20
- extends Delegate
21
- implements IFriggIntegrationManager
22
- {
23
- integration: Integration;
24
- primaryInstance: any;
25
- targetInstance: any;
26
-
27
- static Config: {
28
- name: string;
29
- version: string;
30
- supportedVersions: string[];
31
- events: string[];
32
- };
33
- static integrationManagerClasses: any[];
34
- static integrationTypes: string[];
35
-
36
- constructor(params: any);
37
-
38
- static getInstanceFromIntegrationId(params: {
39
- integrationId: string;
40
- userId?: string;
41
- }): Promise<any>;
42
- static getName(): string;
43
- static getCurrentVersion(): string;
44
-
45
- validateConfig(): Promise<void>;
46
- testAuth(): Promise<void>;
47
-
48
- static getInstance(params: {
49
- userId: string;
50
- integrationId: string;
51
- }): Promise<IntegrationManager>;
52
- static getIntegrationManagerClasses(type: string): any[];
53
-
54
- static createIntegration(
55
- entities: { id: string; user: any },
56
- userId: string,
57
- config: any
58
- ): Promise<any>;
59
-
60
- static getFormattedIntegration(
61
- integration: Integration
62
- ): Promise<FormattedIntegration[]>;
63
- static getIntegrationsForUserId(
64
- userId: string
65
- ): Promise<FormattedIntegration[]>;
66
- static getIntegrationForUserById(
67
- userId: string,
68
- integrationId: string
69
- ): Promise<Integration>;
70
- static deleteIntegrationForUserById(
71
- userId: string,
72
- integrationId: string
73
- ): Promise<void>;
74
- static getIntegrationById(id: string): Promise<Integration>;
75
- static getFilteredIntegrationsForUserId(
76
- userId: string,
77
- filter: any
78
- ): Promise<Integration[]>;
79
- static getCredentialById(credential_id: string): Promise<any>;
80
- static listCredentials(options: any): Promise<any>;
81
- static getEntityById(entity_id: any): Promise<any>;
82
- static listEntities(options: any): Promise<any>;
83
-
84
- processCreate(params: any): Promise<any>;
85
- processUpdate(params: any): Promise<any>;
86
- processDelete(params: any): Promise<any>;
87
-
88
- getConfigOptions(): Promise<any>;
89
- getSampleData(): Promise<any>;
90
- }
91
-
92
- type FormattedIntegration = {
93
- entities: any[];
94
- messages: any;
95
- id: any;
96
- config: any;
97
- version: any;
98
- status: any;
1
+ declare module "@friggframework/integrations" {
2
+ import { Delegate, IFriggDelegate } from "@friggframework/core";
3
+ import { Model } from "mongoose";
4
+
5
+ export class Integration extends Model {
6
+ entities: any[];
7
+ userId: string;
8
+ status: string; // IntegrationStatus
9
+ config: any;
10
+ version: string;
11
+ messages: {
12
+ errors: [];
13
+ warnings: [];
14
+ info: [];
15
+ logs: [];
99
16
  };
100
-
101
- interface IFriggIntegrationManager extends IFriggDelegate {
102
- primaryInstance: any; // Returns the Freshbooks manager instance
103
- targetInstance: any; // Returns a manager e.g. StripeManager instance containing the entitiy, credential, api etc
104
- integration: Integration; // Integration model instance
105
-
106
- validateConfig(): Promise<void>;
107
- testAuth(): Promise<void>;
108
- processCreate(params: any): Promise<any>;
109
- processUpdate(params: any): Promise<any>;
110
- processDelete(params: any): Promise<any>;
111
-
112
- getConfigOptions(): Promise<any>;
113
- getSampleData(): Promise<any>;
114
- }
115
-
116
- export class IntegrationConfigManager
117
- implements IFriggIntegrationConfigManager
118
- {
119
- options: IntegrationOptions[];
120
- primary: any;
121
-
122
- getIntegrationOptions(): Promise<GetIntegrationOptions>;
123
- }
124
-
125
- interface IFriggIntegrationConfigManager {
126
- options: IntegrationOptions[];
127
- primary: any;
128
-
129
- getIntegrationOptions(): Promise<GetIntegrationOptions>;
130
- }
131
-
132
- type GetIntegrationOptions = {
133
- entities: {
134
- primary: any;
135
- options: any[];
136
- autorized: any[];
137
- };
138
- integrations: any[];
17
+ }
18
+
19
+ export class IntegrationManager
20
+ extends Delegate
21
+ implements IFriggIntegrationManager {
22
+ integration: Integration;
23
+ primaryInstance: any;
24
+ targetInstance: any;
25
+
26
+ static Config: {
27
+ name: string;
28
+ version: string;
29
+ supportedVersions: string[];
30
+ events: string[];
139
31
  };
140
-
141
- export class Options implements IFriggIntegrationOptions {
142
- display: IntegrationOptionDisplay;
143
- hasUserConfig: boolean;
144
- isMany: boolean;
145
- module: any;
146
- requiresNewEntity: boolean;
147
- type: string;
148
-
149
- constructor(params: {
150
- display: Partial<IntegrationOptionDisplay>;
151
- type?: string;
152
- hasUserConfig?: boolean;
153
- isMany?: boolean;
154
- requiresNewEntity?: boolean;
155
- module?: any;
156
- });
157
- get(): IntegrationOptions;
158
- }
159
-
160
- interface IFriggIntegrationOptions {
161
- module: any;
162
- type: string;
163
- hasUserConfig: boolean;
164
- isMany: boolean;
165
- requiresNewEntity: boolean;
166
- display: IntegrationOptionDisplay;
167
-
168
- get(): IntegrationOptions;
169
- }
170
-
171
- type IntegrationOptions = {
172
- type: string;
173
- hasUserConfig: boolean;
174
- isMany: boolean;
175
- requiresNewEntity: boolean;
176
- display: IntegrationOptionDisplay;
32
+ static integrationManagerClasses: any[];
33
+ static integrationTypes: string[];
34
+
35
+ constructor(params: any);
36
+
37
+ static getInstanceFromIntegrationId(params: {
38
+ integrationId: string;
39
+ userId?: string;
40
+ }): Promise<any>;
41
+ static getName(): string;
42
+ static getCurrentVersion(): string;
43
+
44
+ validateConfig(): Promise<void>;
45
+ testAuth(): Promise<void>;
46
+
47
+ static getInstance(params: {
48
+ userId: string;
49
+ integrationId: string;
50
+ }): Promise<IntegrationManager>;
51
+ static getIntegrationManagerClasses(type: string): any[];
52
+
53
+ static createIntegration(
54
+ entities: { id: string; user: any },
55
+ userId: string,
56
+ config: any,
57
+ ): Promise<any>;
58
+
59
+ static getFormattedIntegration(
60
+ integration: Integration
61
+ ): Promise<FormattedIntegration[]>;
62
+ static getIntegrationsForUserId(
63
+ userId: string
64
+ ): Promise<FormattedIntegration[]>;
65
+ static getIntegrationForUserById(
66
+ userId: string,
67
+ integrationId: string
68
+ ): Promise<Integration>;
69
+ static deleteIntegrationForUserById(
70
+ userId: string,
71
+ integrationId: string
72
+ ): Promise<void>;
73
+ static getIntegrationById(id: string): Promise<Integration>;
74
+ static getFilteredIntegrationsForUserId(
75
+ userId: string,
76
+ filter: any
77
+ ): Promise<Integration[]>;
78
+ static getCredentialById(credential_id: string): Promise<any>;
79
+ static listCredentials(options: any): Promise<any>;
80
+ static getEntityById(entity_id: any): Promise<any>;
81
+ static listEntities(options: any): Promise<any>;
82
+
83
+ processCreate(params: any): Promise<any>;
84
+ processUpdate(params: any): Promise<any>;
85
+ processDelete(params: any): Promise<any>;
86
+
87
+ getConfigOptions(): Promise<any>;
88
+ getSampleData(): Promise<any>;
89
+ }
90
+
91
+ type FormattedIntegration = {
92
+ entities: any[];
93
+ messages: any;
94
+ id: any;
95
+ config: any;
96
+ version: any;
97
+ status: any;
98
+ };
99
+
100
+ interface IFriggIntegrationManager extends IFriggDelegate {
101
+ primaryInstance: any; // Returns the Freshbooks manager instance
102
+ targetInstance: any; // Returns a manager e.g. StripeManager instance containing the entitiy, credential, api etc
103
+ integration: Integration; // Integration model instance
104
+
105
+ validateConfig(): Promise<void>;
106
+ testAuth(): Promise<void>;
107
+ processCreate(params: any): Promise<any>;
108
+ processUpdate(params: any): Promise<any>;
109
+ processDelete(params: any): Promise<any>;
110
+
111
+ getConfigOptions(): Promise<any>;
112
+ getSampleData(): Promise<any>;
113
+ }
114
+
115
+ export class IntegrationConfigManager
116
+ implements IFriggIntegrationConfigManager {
117
+ options: IntegrationOptions[];
118
+ primary: any;
119
+
120
+ getIntegrationOptions(): Promise<GetIntegrationOptions>;
121
+ }
122
+
123
+ interface IFriggIntegrationConfigManager {
124
+ options: IntegrationOptions[];
125
+ primary: any;
126
+
127
+ getIntegrationOptions(): Promise<GetIntegrationOptions>;
128
+ }
129
+
130
+ type GetIntegrationOptions = {
131
+ entities: {
132
+ primary: any;
133
+ options: any[];
134
+ autorized: any[];
177
135
  };
178
-
179
- type IntegrationOptionDisplay = {
180
- name: string;
181
- description: string;
182
- detailsUrl: string;
183
- icon: string;
184
- };
185
-
186
- interface IFriggIntegrationsPackage {
187
- IntegrationManager: IFriggIntegrationManager;
188
- }
136
+ integrations: any[];
137
+ };
138
+
139
+ export class Options implements IFriggIntegrationOptions {
140
+ display: IntegrationOptionDisplay;
141
+ hasUserConfig: boolean;
142
+ isMany: boolean;
143
+ module: any;
144
+ requiresNewEntity: boolean;
145
+ type: string;
146
+
147
+ constructor(params: {
148
+ display: Partial<IntegrationOptionDisplay>;
149
+ type?: string;
150
+ hasUserConfig?: boolean;
151
+ isMany?: boolean;
152
+ requiresNewEntity?: boolean;
153
+ module?: any;
154
+ });
155
+ get(): IntegrationOptions;
156
+ }
157
+
158
+ interface IFriggIntegrationOptions {
159
+ module: any;
160
+ type: string;
161
+ hasUserConfig: boolean;
162
+ isMany: boolean;
163
+ requiresNewEntity: boolean;
164
+ display: IntegrationOptionDisplay;
165
+
166
+ get(): IntegrationOptions;
167
+ }
168
+
169
+ type IntegrationOptions = {
170
+ type: string;
171
+ hasUserConfig: boolean;
172
+ isMany: boolean;
173
+ requiresNewEntity: boolean;
174
+ display: IntegrationOptionDisplay;
175
+ };
176
+
177
+ type IntegrationOptionDisplay = {
178
+ name: string;
179
+ description: string;
180
+ detailsUrl: string;
181
+ icon: string;
182
+ };
183
+
184
+ interface IFriggIntegrationsPackage {
185
+ IntegrationManager: IFriggIntegrationManager;
186
+ }
189
187
  }
@@ -1,31 +1,31 @@
1
- declare module '@friggframework/lambda/TimeoutCatcher' {
2
- export class TimeoutCatcher implements IFriggTimeoutCatcher {
3
- isFinished: boolean;
4
- waitTime: number;
1
+ declare module "@friggframework/lambda/TimeoutCatcher" {
2
+ export class TimeoutCatcher implements IFriggTimeoutCatcher {
3
+ isFinished: boolean;
4
+ waitTime: number;
5
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
- }
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
13
 
14
- interface IFriggTimeoutCatcher {
15
- isFinished: boolean;
16
- work: () => Promise<any>;
17
- cleanUp: () => Promise<any>;
18
- waitTime: number;
14
+ interface IFriggTimeoutCatcher {
15
+ isFinished: boolean;
16
+ work: () => Promise<any>;
17
+ cleanUp: () => Promise<any>;
18
+ waitTime: number;
19
19
 
20
- watch(): Promise<boolean>;
21
- doWork(): Promise<void>;
22
- exitBeforeTimeout(): Promise<void>;
23
- }
20
+ watch(): Promise<boolean>;
21
+ doWork(): Promise<void>;
22
+ exitBeforeTimeout(): Promise<void>;
23
+ }
24
24
 
25
- type TimeoutCatcherConstructor = {
26
- work: () => Promise<any>;
27
- timeout: number;
28
- cleanUp?: () => Promise<any>;
29
- cleanUpTime?: number;
30
- };
25
+ type TimeoutCatcherConstructor = {
26
+ work: () => Promise<any>;
27
+ timeout: number;
28
+ cleanUp?: () => Promise<any>;
29
+ cleanUpTime?: number;
30
+ };
31
31
  }
@@ -1,5 +1,5 @@
1
- declare module '@friggframework/logs/logger' {
2
- export function debug(...messages: any[]): void;
3
- export function initDebugLog(...initMessages: any[]): void;
4
- export function flushDebugLog(error: any): void;
1
+ declare module "@friggframework/logs/logger" {
2
+ export function debug(...messages: any[]): void;
3
+ export function initDebugLog(...initMessages: any[]): void;
4
+ export function flushDebugLog(error: any): void;
5
5
  }