@friggframework/core 0.2.31-v1-alpha.6 → 1.0.1-v1-alpha-package-update.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 (193) hide show
  1. package/assertions/CHANGELOG.md +87 -0
  2. package/assertions/LICENSE.md +9 -0
  3. package/assertions/README.md +3 -0
  4. package/assertions/bump.txt +1 -0
  5. package/assertions/get.js +139 -0
  6. package/assertions/index.js +19 -0
  7. package/assertions/is-equal.js +17 -0
  8. package/associations/LICENSE.md +9 -0
  9. package/associations/README.md +3 -0
  10. package/associations/association.js +78 -0
  11. package/associations/bump3.txt +0 -0
  12. package/associations/jest.config.js +5 -0
  13. package/associations/model.js +54 -0
  14. package/bump.txt +0 -0
  15. package/core/.eslintrc.json +3 -0
  16. package/{Delegate.js → core/Delegate.js} +1 -1
  17. package/core/LICENSE.md +9 -0
  18. package/{Worker.js → core/Worker.js} +2 -2
  19. package/core/bump3.txt +0 -0
  20. package/{create-handler.js → core/create-handler.js} +2 -2
  21. package/core/index.js +6 -0
  22. package/core/jest.config.js +5 -0
  23. package/database/.eslintrc.json +3 -0
  24. package/database/CHANGELOG.md +97 -0
  25. package/database/LICENSE.md +9 -0
  26. package/database/README.md +3 -0
  27. package/database/bump3.txt +0 -0
  28. package/database/index.js +17 -0
  29. package/database/jest.config.js +5 -0
  30. package/database/models/IndividualUser.js +76 -0
  31. package/database/models/OrganizationUser.js +29 -0
  32. package/database/models/State.js +9 -0
  33. package/database/models/Token.js +70 -0
  34. package/database/models/UserModel.js +7 -0
  35. package/database/mongo.js +45 -0
  36. package/database/mongoose.js +5 -0
  37. package/encrypt/.eslintrc.json +3 -0
  38. package/encrypt/CHANGELOG.md +65 -0
  39. package/encrypt/Cryptor.js +236 -0
  40. package/encrypt/Cryptor.test.js +32 -0
  41. package/encrypt/LICENSE.md +9 -0
  42. package/encrypt/README.md +3 -0
  43. package/encrypt/aes.js +27 -0
  44. package/encrypt/bump3.txt +0 -0
  45. package/encrypt/encrypt.js +124 -0
  46. package/encrypt/encrypt.test.js +1068 -0
  47. package/encrypt/index.js +3 -0
  48. package/encrypt/jest.config.js +5 -0
  49. package/encrypt/test-encrypt.js +107 -0
  50. package/errors/.eslintrc.json +3 -0
  51. package/errors/CHANGELOG.md +44 -0
  52. package/errors/LICENSE.md +9 -0
  53. package/errors/README.md +3 -0
  54. package/errors/base-error.js +23 -0
  55. package/errors/base-error.test.js +32 -0
  56. package/errors/bump.txt +1 -0
  57. package/errors/bump3.txt +0 -0
  58. package/errors/fetch-error.js +72 -0
  59. package/errors/fetch-error.test.js +79 -0
  60. package/errors/halt-error.js +10 -0
  61. package/errors/halt-error.test.js +11 -0
  62. package/errors/index.js +15 -0
  63. package/errors/jest.config.js +5 -0
  64. package/errors/validation-errors.js +23 -0
  65. package/errors/validation-errors.test.js +120 -0
  66. package/eslint-config/.eslintrc.json +3 -0
  67. package/eslint-config/CHANGELOG.md +17 -0
  68. package/eslint-config/LICENSE.md +9 -0
  69. package/eslint-config/README.md +3 -0
  70. package/eslint-config/bump3.txt +0 -0
  71. package/eslint-config/index.js +38 -0
  72. package/index.js +29 -5
  73. package/integrations/.eslintrc.json +3 -0
  74. package/integrations/CHANGELOG.md +244 -0
  75. package/integrations/LICENSE.md +9 -0
  76. package/integrations/README.md +3 -0
  77. package/integrations/bump3.txt +0 -0
  78. package/integrations/create-frigg-backend.js +31 -0
  79. package/integrations/index.js +19 -0
  80. package/integrations/integration-base.js +162 -0
  81. package/integrations/integration-factory.js +166 -0
  82. package/integrations/integration-mapping.js +43 -0
  83. package/integrations/integration-model.js +42 -0
  84. package/integrations/integration-router.js +367 -0
  85. package/integrations/integration-user.js +144 -0
  86. package/integrations/jest-setup.js +2 -0
  87. package/integrations/jest-teardown.js +2 -0
  88. package/integrations/jest.config.js +12 -0
  89. package/integrations/options.js +54 -0
  90. package/integrations/test/integration-base.test.js +143 -0
  91. package/lambda/README.md +3 -0
  92. package/lambda/TimeoutCatcher.js +43 -0
  93. package/lambda/TimeoutCatcher.test.js +68 -0
  94. package/lambda/bump3.txt +0 -0
  95. package/lambda/index.js +3 -0
  96. package/lambda/jest.config.js +3 -0
  97. package/logs/.eslintrc.json +3 -0
  98. package/logs/CHANGELOG.md +57 -0
  99. package/logs/LICENSE.md +9 -0
  100. package/logs/README.md +3 -0
  101. package/logs/bump3.txt +0 -0
  102. package/logs/index.js +7 -0
  103. package/logs/jest.config.js +5 -0
  104. package/logs/logger.js +69 -0
  105. package/logs/logger.test.js +76 -0
  106. package/migrations/README.md +3 -0
  107. package/migrations/bump3.txt +0 -0
  108. package/migrations/index.js +9 -0
  109. package/migrations/jest.config.js +3 -0
  110. package/migrations/manager.js +33 -0
  111. package/migrations/migrator.js +170 -0
  112. package/migrations/options.js +28 -0
  113. package/module-plugin/.eslintrc.json +3 -0
  114. package/module-plugin/CHANGELOG.md +224 -0
  115. package/module-plugin/LICENSE.md +9 -0
  116. package/module-plugin/ModuleConstants.js +10 -0
  117. package/module-plugin/README.md +3 -0
  118. package/module-plugin/auther.js +342 -0
  119. package/module-plugin/bump3.txt +0 -0
  120. package/module-plugin/credential.js +22 -0
  121. package/module-plugin/entity-manager.js +70 -0
  122. package/module-plugin/entity.js +46 -0
  123. package/module-plugin/index.js +25 -0
  124. package/module-plugin/jest-setup.js +3 -0
  125. package/module-plugin/jest-teardown.js +2 -0
  126. package/module-plugin/jest.config.js +20 -0
  127. package/module-plugin/manager.js +169 -0
  128. package/module-plugin/module-factory.js +60 -0
  129. package/module-plugin/requester/api-key.js +36 -0
  130. package/module-plugin/requester/basic.js +43 -0
  131. package/module-plugin/requester/oauth-2.js +219 -0
  132. package/module-plugin/requester/requester.js +150 -0
  133. package/module-plugin/requester/requester.test.js +28 -0
  134. package/module-plugin/test/auther.test.js +97 -0
  135. package/module-plugin/test/mock-api/api.js +29 -0
  136. package/module-plugin/test/mock-api/definition.js +48 -0
  137. package/module-plugin/test/mock-api/mocks/hubspot.js +43 -0
  138. package/package.json +37 -13
  139. package/prettier-config/.eslintrc.json +3 -0
  140. package/prettier-config/CHANGELOG.md +17 -0
  141. package/prettier-config/LICENSE.md +9 -0
  142. package/prettier-config/README.md +3 -0
  143. package/prettier-config/bump3.txt +0 -0
  144. package/prettier-config/index.js +6 -0
  145. package/syncs/README.md +3 -0
  146. package/syncs/bump3.txt +0 -0
  147. package/syncs/jest.config.js +5 -0
  148. package/syncs/manager.js +466 -0
  149. package/syncs/model.js +62 -0
  150. package/syncs/sync.js +114 -0
  151. package/test-environment/.eslintrc.json +3 -0
  152. package/test-environment/Authenticator.js +73 -0
  153. package/test-environment/CHANGELOG.md +46 -0
  154. package/test-environment/LICENSE.md +9 -0
  155. package/test-environment/README.md +3 -0
  156. package/test-environment/auther-definition-method-tester.js +45 -0
  157. package/test-environment/auther-definition-tester.js +104 -0
  158. package/test-environment/bump3.txt +0 -0
  159. package/test-environment/index.js +24 -0
  160. package/test-environment/integration-validator.js +2 -0
  161. package/test-environment/jest-global-setup.js +6 -0
  162. package/test-environment/jest-global-teardown.js +3 -0
  163. package/test-environment/jest-preset.js +14 -0
  164. package/test-environment/mock-api-readme.md +102 -0
  165. package/test-environment/mock-api.js +284 -0
  166. package/test-environment/mock-integration.js +82 -0
  167. package/test-environment/mongodb.js +22 -0
  168. package/test-environment/override-environment.js +11 -0
  169. package/types/CHANGELOG.md +49 -0
  170. package/types/README.md +24 -0
  171. package/types/assertions/index.d.ts +83 -0
  172. package/types/associations/index.d.ts +74 -0
  173. package/types/bump3.txt +0 -0
  174. package/types/core/index.d.ts +54 -0
  175. package/types/database/index.d.ts +3 -0
  176. package/types/encrypt/index.d.ts +5 -0
  177. package/types/errors/index.d.ts +66 -0
  178. package/types/eslint-config/index.d.ts +41 -0
  179. package/types/index.d.ts +14 -0
  180. package/types/integrations/index.d.ts +191 -0
  181. package/types/lambda/index.d.ts +31 -0
  182. package/types/logs/index.d.ts +5 -0
  183. package/types/module-plugin/index.d.ts +293 -0
  184. package/types/prettier-config/index.d.ts +6 -0
  185. package/types/syncs/index.d.ts +128 -0
  186. package/types/test-environment/index.d.ts +17 -0
  187. package/types/tsconfig.json +103 -0
  188. /package/{.eslintrc.json → assertions/.eslintrc.json} +0 -0
  189. /package/{bump3.txt → assertions/bump3.txt} +0 -0
  190. /package/{jest.config.js → assertions/jest.config.js} +0 -0
  191. /package/{CHANGELOG.md → core/CHANGELOG.md} +0 -0
  192. /package/{README.md → core/README.md} +0 -0
  193. /package/{load-installed-modules.js → core/load-installed-modules.js} +0 -0
@@ -0,0 +1,5 @@
1
+ declare module "@friggframework/encrypt" {
2
+ import { Schema } from "mongoose";
3
+
4
+ export function Encrypt(schema: Schema, options: any): void;
5
+ }
@@ -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
+ }
@@ -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
+ }
@@ -0,0 +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;
5
+ }
@@ -0,0 +1,293 @@
1
+ declare module "@friggframework/module-plugin" {
2
+ import { Model } from "mongoose";
3
+ import { Delegate, IFriggDelegate } from "@friggframework/core";
4
+
5
+ export class Credential extends Model {
6
+ userId: string;
7
+ auth_is_valid: boolean;
8
+ subType: string;
9
+ externalId: string;
10
+ }
11
+
12
+ export class EntityManager implements IFriggEntityManager {
13
+ static primaryEntityClass: any;
14
+ static entityManagerClasses: any[];
15
+ static entityTypes: string[];
16
+ static getEntitiesForUser(userId: string): Promise<any[]>;
17
+ static checkIsValidType(entityType: string): boolean;
18
+ static getEntityManagerClass(entityType?: string): any;
19
+
20
+ static getEntityManagerInstanceFromEntityId(
21
+ entityId: string,
22
+ userId: string
23
+ ): Promise<any>;
24
+ }
25
+
26
+ interface IFriggEntityManager {}
27
+
28
+ export class Entity extends Model {
29
+ credentialId: string;
30
+ subType: string;
31
+ userId: string;
32
+ name: string;
33
+ externalId: string;
34
+ }
35
+
36
+ export type MappedEntity = Entity & { id: string; type: any };
37
+ export class ModuleManager extends Delegate implements IFriggModuleManager {
38
+ static Entity: Entity;
39
+ static Credential: Credential;
40
+
41
+ constructor(params: { userId: string });
42
+
43
+ static getName(): any;
44
+ static getInstance(params: any): Promise<any>;
45
+ static getEntitiesForUserId(userId: string): Promise<MappedEntity[]>;
46
+
47
+ batchCreateSyncObjects(syncObjects: any, syncManager: any): Promise<any>;
48
+ batchUpdateSyncObjects(syncObjects: any, syncManager: any): Promise<any>;
49
+ findOrCreateEntity(params: any): Promise<any>;
50
+ getAllSyncObjects(SyncClass: any): Promise<any>;
51
+ getAuthorizationRequirements(params: any): Promise<any>;
52
+ getEntityId(): Promise<string>;
53
+ getEntityOptions(): Promise<any>;
54
+ markCredentialsInvalid(): Promise<Credential>;
55
+ processAuthorizationCallback(params: any): Promise<any>;
56
+ testAuth(params: any): Promise<any>;
57
+ validateAuthorizationRequirements(): Promise<boolean>;
58
+ }
59
+
60
+ interface IFriggModuleManager extends IFriggDelegate {
61
+ getEntityId(): Promise<string>;
62
+ validateAuthorizationRequirements(): Promise<boolean>;
63
+ getAuthorizationRequirements(params: any): Promise<any>;
64
+ testAuth(params: any): Promise<any>;
65
+ processAuthorizationCallback(params: any): Promise<any>;
66
+ getEntityOptions(): Promise<any>;
67
+ findOrCreateEntity(params: any): Promise<any>;
68
+ getAllSyncObjects(SyncClass: any): Promise<any>;
69
+ batchCreateSyncObjects(syncObjects: any, syncManager: any): Promise<any>;
70
+ batchUpdateSyncObjects(syncObjects: any, syncManager: any): Promise<any>;
71
+ markCredentialsInvalid(): Promise<Credential>;
72
+ }
73
+
74
+ export class Requester implements IFriggRequester {
75
+ DLGT_INVALID_AUTH: string;
76
+ backOff: number[];
77
+ fetch: any;
78
+ isRefreshable: boolean;
79
+ refreshCount: number;
80
+
81
+ _delete(options: RequestOptions): Promise<any>;
82
+ _get(options: RequestOptions): Promise<any>;
83
+ _patch(options: RequestOptions): Promise<any>;
84
+ _post(options: RequestOptions, stringify?: boolean): Promise<any>;
85
+ _put(options: RequestOptions): Promise<any>;
86
+ _request(
87
+ url: string,
88
+ options: Omit<RequestOptions, "url">,
89
+ i?: number
90
+ ): Promise<any>;
91
+ parseBody(response: any): Promise<any>;
92
+ refreshAuth(): Promise<any>;
93
+
94
+ delegate: any;
95
+ delegateTypes: any[];
96
+
97
+ notify(delegateString: string, object?: any): Promise<any>;
98
+ receiveNotification(
99
+ notifier: any,
100
+ delegateString: string,
101
+ object?: any
102
+ ): Promise<any>;
103
+ }
104
+
105
+ interface IFriggRequester extends IFriggDelegate {
106
+ backOff: number[];
107
+ isRefreshable: boolean;
108
+ refreshCount: number;
109
+ DLGT_INVALID_AUTH: string;
110
+ fetch: any;
111
+
112
+ parseBody(response: any): Promise<any>;
113
+ _request(
114
+ url: string,
115
+ options: Omit<RequestOptions, "url">,
116
+ i?: number
117
+ ): Promise<any>;
118
+ _get(options: RequestOptions): Promise<any>;
119
+ _post(options: RequestOptions, stringify?: boolean): Promise<any>;
120
+ _patch(options: RequestOptions): Promise<any>;
121
+ _put(options: RequestOptions): Promise<any>;
122
+ _delete(options: RequestOptions): Promise<any>;
123
+ refreshAuth(): Promise<any>;
124
+ }
125
+
126
+ type RequestOptions = {
127
+ url: string;
128
+ headers?: object;
129
+ query?: object;
130
+ returnFullRes?: boolean;
131
+ body?: any;
132
+ };
133
+
134
+ type RequesterConstructor = {
135
+ backOff?: number[];
136
+ fetch?: any;
137
+ };
138
+
139
+ export class ApiKeyRequester
140
+ extends Requester
141
+ implements IFriggApiKeyRequester
142
+ {
143
+ API_KEY_NAME: string;
144
+ API_KEY_VALUE: any;
145
+
146
+ constructor(params: RequesterConstructor);
147
+ addAuthHeaders(headers: object): Promise<object>;
148
+ isAuthenticated(): boolean;
149
+ setApiKey(api_key: any): void;
150
+ }
151
+
152
+ interface IFriggApiKeyRequester extends IFriggRequester {
153
+ API_KEY_NAME: string;
154
+ API_KEY_VALUE: string;
155
+
156
+ addAuthHeaders(headers: object): Promise<object>;
157
+ isAuthenticated(): boolean;
158
+ setApiKey(api_key: string): void;
159
+ }
160
+
161
+ export class BasicAuthRequester
162
+ extends Requester
163
+ implements IFriggBasicAuthRequester
164
+ {
165
+ password: string;
166
+ username: string;
167
+
168
+ constructor(params: BasicAuthRequesterConstructor);
169
+ addAuthHeaders(headers: object): Promise<object>;
170
+ isAuthenticated(): boolean;
171
+ setPassword(password: string): void;
172
+ setUsername(username: string): void;
173
+ }
174
+
175
+ interface IFriggBasicAuthRequester extends IFriggRequester {
176
+ username: string;
177
+ password: string;
178
+
179
+ addAuthHeaders(headers: object): Promise<object>;
180
+ isAuthenticated(): boolean;
181
+ setUsername(username: string): void;
182
+ setPassword(password: string): void;
183
+ }
184
+
185
+ type BasicAuthRequesterConstructor = RequesterConstructor & {
186
+ username?: string;
187
+ password?: string;
188
+ };
189
+
190
+ export class OAuth2Requester
191
+ extends Requester
192
+ implements IFriggOAuth2Requester
193
+ {
194
+ DLGT_TOKEN_DEAUTHORIZED: string;
195
+ DLGT_TOKEN_UPDATE: string;
196
+ accessTokenExpire: any;
197
+ access_token: string;
198
+ audience: any;
199
+ authorizationUri: any;
200
+ baseURL: string;
201
+ client_id: string;
202
+ client_secret: string;
203
+ grant_type: string;
204
+ password: string;
205
+ redirect_uri: string;
206
+ refreshTokenExpire: any;
207
+ refresh_token: string;
208
+ scope: string;
209
+ state: any;
210
+ username: string;
211
+
212
+ constructor(params: OAuth2RequesterConstructor);
213
+
214
+ addAuthHeaders(headers: object): Promise<object>;
215
+ getAuthorizationUri(): string;
216
+ getTokenFromClientCredentials(): Promise<Token>;
217
+ getTokenFromCode(code: string): Promise<Token>;
218
+ getTokenFromCodeBasicAuthHeader(code: string): Promise<Token>;
219
+ getTokenFromUsernamePassword(): Promise<Token>;
220
+ isAuthenticated(): boolean;
221
+ refreshAccessToken(refreshTokenObject: {
222
+ refresh_token: string;
223
+ }): Promise<Token>;
224
+ setTokens(params: Token): Promise<void>;
225
+ }
226
+ interface IFriggOAuth2Requester extends IFriggRequester {
227
+ DLGT_TOKEN_UPDATE: string;
228
+ DLGT_TOKEN_DEAUTHORIZED: string;
229
+
230
+ grant_type?: string;
231
+ client_id?: string;
232
+ client_secret?: string;
233
+ redirect_uri?: string;
234
+ scope?: string;
235
+ authorizationUri?: any;
236
+ baseURL?: string;
237
+ access_token?: string;
238
+ refresh_token?: string;
239
+ accessTokenExpire?: any;
240
+ refreshTokenExpire?: any;
241
+ audience?: any;
242
+ username?: string;
243
+ password?: string;
244
+ state?: any;
245
+
246
+ setTokens(params: Token): Promise<void>;
247
+ getAuthorizationUri(): string;
248
+ getTokenFromCode(code: string): Promise<Token>;
249
+ getTokenFromCodeBasicAuthHeader(code: string): Promise<Token>;
250
+ refreshAccessToken(refreshTokenObject: {
251
+ refresh_token: string;
252
+ }): Promise<Token>;
253
+ addAuthHeaders(headers: object): Promise<object>;
254
+ isAuthenticated(): boolean;
255
+ refreshAuth(): Promise<void>;
256
+ getTokenFromUsernamePassword(): Promise<Token>;
257
+ getTokenFromClientCredentials(): Promise<Token>;
258
+ }
259
+
260
+ type Token = {
261
+ access_token?: string;
262
+ refresh_token?: string;
263
+ expires_in: any;
264
+ x_refresh_token_expires_in: any;
265
+ };
266
+
267
+ type OAuth2RequesterConstructor = {
268
+ grant_type?: string;
269
+ client_id?: string;
270
+ client_secret?: string;
271
+ redirect_uri?: string;
272
+ scope?: string;
273
+ authorizationUri?: any;
274
+ baseURL?: string;
275
+ access_token?: string;
276
+ refresh_token?: string;
277
+ accessTokenExpire?: any;
278
+ refreshTokenExpire?: any;
279
+ audience?: any;
280
+ username?: string;
281
+ password?: string;
282
+ state?: any;
283
+ };
284
+
285
+ export const ModuleConstants: {
286
+ authType: {
287
+ oauth2: "oauth2";
288
+ oauth1: "oauth1";
289
+ basic: "basic";
290
+ apiKey: "apiKey";
291
+ };
292
+ };
293
+ }
@@ -0,0 +1,6 @@
1
+ declare module "@friggframework/prettier-config" {
2
+ export const semi: true;
3
+ export const tabWidth = 4;
4
+ export const singleQuote = true;
5
+ export const useTabs: false;
6
+ }