@friggframework/core 2.0.0--canary.548.c8ae0ca.0 → 2.0.0--canary.545.c40eca4.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/CHANGELOG.md +66 -67
- package/CLAUDE.md +148 -124
- package/README.md +165 -130
- package/admin-scripts/index.js +52 -0
- package/admin-scripts/repositories/admin-api-key-repository-documentdb.js +21 -0
- package/admin-scripts/repositories/admin-api-key-repository-factory.js +51 -0
- package/admin-scripts/repositories/admin-api-key-repository-interface.js +121 -0
- package/admin-scripts/repositories/admin-api-key-repository-mongo.js +155 -0
- package/admin-scripts/repositories/admin-api-key-repository-postgres.js +189 -0
- package/admin-scripts/repositories/admin-process-repository-documentdb.js +21 -0
- package/admin-scripts/repositories/admin-process-repository-factory.js +49 -0
- package/admin-scripts/repositories/admin-process-repository-interface.js +150 -0
- package/admin-scripts/repositories/admin-process-repository-mongo.js +213 -0
- package/admin-scripts/repositories/admin-process-repository-postgres.js +251 -0
- package/admin-scripts/repositories/script-execution-repository-documentdb.js +21 -0
- package/admin-scripts/repositories/script-execution-repository-factory.js +51 -0
- package/admin-scripts/repositories/script-execution-repository-interface.js +193 -0
- package/admin-scripts/repositories/script-execution-repository-mongo.js +278 -0
- package/admin-scripts/repositories/script-execution-repository-postgres.js +320 -0
- package/admin-scripts/repositories/script-schedule-repository-documentdb.js +21 -0
- package/admin-scripts/repositories/script-schedule-repository-factory.js +49 -0
- package/admin-scripts/repositories/script-schedule-repository-interface.js +108 -0
- package/admin-scripts/repositories/script-schedule-repository-mongo.js +179 -0
- package/admin-scripts/repositories/script-schedule-repository-postgres.js +210 -0
- package/application/commands/admin-script-commands.js +348 -0
- package/application/commands/integration-commands.js +12 -6
- package/application/index.js +5 -3
- package/assertions/get.js +17 -7
- package/associations/association.js +59 -57
- package/core/CLAUDE.md +222 -156
- package/core/Worker.js +33 -12
- package/credential/credential-router.js +262 -0
- package/credential/repositories/credential-repository-documentdb.js +71 -1
- package/credential/repositories/credential-repository-factory.js +4 -6
- package/credential/repositories/credential-repository-interface.js +8 -2
- package/credential/repositories/credential-repository-mongo.js +45 -4
- package/credential/repositories/credential-repository-postgres.js +44 -3
- package/credential/repositories/credential-repository.js +3 -1
- package/credential/use-cases/delete-credential-for-user.js +50 -0
- package/credential/use-cases/get-credential-for-user.js +21 -3
- package/credential/use-cases/list-credentials-for-user.js +31 -0
- package/credential/use-cases/reauthorize-credential.js +103 -0
- package/credential/use-cases/update-authentication-status.js +5 -2
- package/database/MONGODB_TRANSACTION_FIX.md +72 -52
- package/database/config.js +13 -59
- package/database/documentdb-encryption-service.js +29 -13
- package/database/documentdb-utils.js +21 -12
- package/database/encryption/README.md +53 -36
- package/database/encryption/encryption-schema-registry.js +29 -23
- package/database/encryption/field-encryption-service.js +15 -4
- package/database/encryption/logger.js +3 -2
- package/database/encryption/prisma-encryption-extension.js +5 -8
- package/database/prisma.js +22 -14
- package/database/repositories/health-check-repository-factory.js +7 -5
- package/database/repositories/health-check-repository-interface.js +15 -5
- package/database/repositories/health-check-repository-postgres.js +1 -1
- package/database/use-cases/check-database-health-use-case.js +3 -2
- package/database/use-cases/check-database-state-use-case.js +8 -7
- package/database/use-cases/get-database-state-via-worker-use-case.js +15 -12
- package/database/use-cases/get-migration-status-use-case.js +4 -2
- package/database/use-cases/run-database-migration-use-case.js +41 -9
- package/database/use-cases/test-encryption-use-case.js +4 -5
- package/database/use-cases/trigger-database-migration-use-case.js +9 -8
- package/database/utils/mongodb-collection-utils.js +11 -3
- package/database/utils/mongodb-schema-init.js +10 -4
- package/database/utils/prisma-runner.js +144 -74
- package/database/utils/prisma-schema-parser.js +2 -2
- package/docs/PROCESS_MANAGEMENT_QUEUE_SPEC.md +135 -80
- package/encrypt/Cryptor.js +54 -49
- package/encrypt/aes-encryption-key-provider.js +82 -0
- package/encrypt/encryption-key-provider-interface.js +50 -0
- package/errors/fetch-error.js +1 -1
- package/generated/prisma-mongodb/edge.js +59 -4
- package/generated/prisma-mongodb/index-browser.js +49 -1
- package/generated/prisma-mongodb/index.d.ts +4023 -61
- package/generated/prisma-mongodb/index.js +59 -4
- package/generated/prisma-mongodb/package.json +1 -1
- package/generated/prisma-mongodb/schema.prisma +87 -0
- package/generated/prisma-mongodb/wasm.js +59 -4
- package/generated/prisma-postgresql/edge.js +58 -4
- package/generated/prisma-postgresql/index-browser.js +48 -1
- package/generated/prisma-postgresql/index.d.ts +4738 -54
- package/generated/prisma-postgresql/index.js +58 -4
- package/generated/prisma-postgresql/package.json +1 -1
- package/generated/prisma-postgresql/schema.prisma +85 -0
- package/generated/prisma-postgresql/wasm.js +58 -4
- package/handlers/WEBHOOKS.md +104 -81
- package/handlers/app-definition-loader.js +53 -10
- package/handlers/app-handler-helpers.js +14 -3
- package/handlers/backend-utils.js +0 -1
- package/handlers/database-migration-handler.js +64 -45
- package/handlers/middleware/admin-auth.js +53 -0
- package/handlers/routers/HEALTHCHECK.md +170 -135
- package/handlers/routers/admin.js +474 -0
- package/handlers/routers/auth.js +51 -9
- package/handlers/routers/db-migration.handler.js +2 -3
- package/handlers/routers/db-migration.js +102 -66
- package/handlers/routers/docs.js +180 -0
- package/handlers/routers/health.js +84 -283
- package/handlers/routers/integration-defined-routers.js +44 -33
- package/handlers/routers/integration-webhook-routers.js +73 -52
- package/handlers/routers/middleware/loadUser.js +39 -0
- package/handlers/routers/middleware/requireAdmin.js +43 -0
- package/handlers/routers/middleware/requireLoggedInUser.js +19 -0
- package/handlers/routers/user.js +30 -14
- package/handlers/routers/websocket.js +18 -4
- package/handlers/use-cases/check-integrations-health-use-case.js +13 -6
- package/handlers/workers/db-migration.js +74 -35
- package/handlers/workers/integration-defined-workers.js +31 -20
- package/index.js +50 -16
- package/infrastructure/scheduler/index.js +15 -11
- package/infrastructure/scheduler/netlify-scheduler-adapter.js +185 -0
- package/infrastructure/scheduler/scheduler-service-factory.js +38 -31
- package/integrations/WEBHOOK-QUICKSTART.md +21 -14
- package/integrations/index.js +4 -0
- package/integrations/integration-base.js +9 -6
- package/integrations/integration-router.js +1828 -157
- package/integrations/options.js +47 -20
- package/integrations/repositories/integration-mapping-repository-factory.js +4 -8
- package/integrations/repositories/integration-repository-documentdb.js +53 -24
- package/integrations/repositories/integration-repository-factory.js +6 -6
- package/integrations/repositories/integration-repository-interface.js +27 -9
- package/integrations/repositories/integration-repository-postgres.js +3 -3
- package/integrations/repositories/process-repository-factory.js +4 -7
- package/integrations/repositories/process-repository-interface.js +9 -5
- package/integrations/repositories/process-repository-mongo.js +7 -3
- package/integrations/repositories/process-repository-postgres.js +2 -2
- package/integrations/tests/doubles/config-capturing-integration.js +9 -8
- package/integrations/tests/doubles/dummy-integration-class.js +81 -8
- package/integrations/tests/doubles/test-integration-repository.js +51 -11
- package/integrations/use-cases/create-integration.js +36 -32
- package/integrations/use-cases/create-process.js +20 -9
- package/integrations/use-cases/delete-integration-for-user.js +5 -4
- package/integrations/use-cases/execute-proxy-request.js +564 -0
- package/integrations/use-cases/get-integration-for-user.js +25 -10
- package/integrations/use-cases/get-integration-instance-by-definition.js +13 -7
- package/integrations/use-cases/get-integrations-for-user.js +4 -1
- package/integrations/use-cases/get-possible-integrations.js +1 -1
- package/integrations/use-cases/get-process.js +5 -6
- package/integrations/use-cases/index.js +3 -1
- package/integrations/use-cases/load-integration-context.js +1 -5
- package/integrations/use-cases/update-process-state.js +10 -8
- package/integrations/utils/map-integration-dto.js +9 -3
- package/jest-setup.js +1 -1
- package/jest-teardown.js +1 -1
- package/lambda/TimeoutCatcher.js +32 -30
- package/lambda/index.js +1 -1
- package/logs/index.js +3 -3
- package/modules/domain/entities/AuthorizationSession.js +131 -0
- package/modules/domain/entities/index.js +10 -0
- package/modules/module.js +4 -9
- package/modules/repositories/authorization-session-repository-factory.js +53 -0
- package/modules/repositories/authorization-session-repository-interface.js +75 -0
- package/modules/repositories/authorization-session-repository-mongo.js +169 -0
- package/modules/repositories/authorization-session-repository-postgres.js +170 -0
- package/modules/repositories/module-repository-documentdb.js +89 -41
- package/modules/repositories/module-repository-factory.js +4 -6
- package/modules/repositories/module-repository-interface.js +13 -0
- package/modules/repositories/module-repository-mongo.js +40 -5
- package/modules/repositories/module-repository-postgres.js +42 -5
- package/modules/repositories/module-repository.js +28 -0
- package/modules/requester/api-key.js +0 -2
- package/modules/requester/basic.js +0 -1
- package/modules/requester/oauth-2.js +3 -14
- package/modules/test/mock-api/definition.js +15 -10
- package/modules/test/mock-api/mocks/hubspot.js +36 -36
- package/modules/tests/doubles/test-module-factory.js +10 -4
- package/modules/tests/doubles/test-module-repository.js +1 -1
- package/modules/use-cases/delete-module-entity.js +23 -0
- package/modules/use-cases/get-authorization-requirements.js +110 -0
- package/modules/use-cases/get-entities-for-user.js +1 -1
- package/modules/use-cases/get-entity-options-by-id.js +8 -6
- package/modules/use-cases/get-module-entity-by-id.js +16 -0
- package/modules/use-cases/get-module.js +12 -9
- package/modules/use-cases/process-authorization-callback.js +12 -6
- package/modules/use-cases/process-authorization-step.js +160 -0
- package/modules/use-cases/refresh-entity-options.js +8 -6
- package/modules/use-cases/start-authorization-session.js +86 -0
- package/modules/use-cases/test-module-auth.js +8 -6
- package/modules/use-cases/update-module-entity.js +27 -0
- package/modules/utils/map-module-dto.js +2 -2
- package/openapi/openapi-spec-generator.js +370 -0
- package/openapi/openapi-v1.yaml +1360 -0
- package/openapi/openapi-v2.yaml +1535 -0
- package/package.json +7 -9
- package/prisma-mongodb/schema.prisma +87 -0
- package/prisma-postgresql/migrations/20260222000000_add_admin_process_and_script_schedule/migration.sql +55 -0
- package/prisma-postgresql/schema.prisma +85 -0
- package/providers/index.js +13 -0
- package/providers/resolve-provider.js +93 -0
- package/queues/index.js +19 -0
- package/queues/providers/index.js +7 -0
- package/queues/providers/netlify-background-provider.js +76 -0
- package/queues/providers/qstash-queue-provider.js +122 -0
- package/queues/queue-client-interface.js +55 -0
- package/queues/queue-provider-factory.js +93 -0
- package/queues/queue-provider.js +46 -0
- package/queues/queuer-util.js +33 -25
- package/syncs/repositories/sync-repository-documentdb.js +39 -19
- package/syncs/repositories/sync-repository-factory.js +4 -4
- package/syncs/repositories/sync-repository-interface.js +6 -2
- package/syncs/repositories/sync-repository-postgres.js +19 -13
- package/syncs/sync.js +104 -100
- package/token/repositories/token-repository-factory.js +4 -6
- package/types/assertions/index.d.ts +72 -72
- package/types/core/index.d.ts +98 -53
- package/types/errors/index.d.ts +61 -54
- package/types/eslint-config/index.d.ts +40 -40
- package/types/lambda/index.d.ts +26 -26
- package/types/logs/index.d.ts +4 -4
- package/types/prettier-config/index.d.ts +5 -5
- package/types/test-environment/index.d.ts +14 -14
- package/types/tsconfig.json +95 -93
- package/user/repositories/user-repository-factory.js +4 -4
- package/user/tests/doubles/test-user-repository.js +5 -2
- package/user/use-cases/authenticate-user.js +2 -4
- package/user/use-cases/authenticate-with-shared-secret.js +1 -1
- package/user/use-cases/create-individual-user.js +8 -7
- package/user/use-cases/create-organization-user.js +1 -1
- package/user/use-cases/create-token-for-user-id.js +1 -1
- package/user/use-cases/delete-user.js +47 -0
- package/user/use-cases/get-user-from-adopter-jwt.js +0 -2
- package/user/use-cases/get-user-from-bearer-token.js +7 -3
- package/user/use-cases/get-user-from-x-frigg-headers.js +14 -11
- package/user/use-cases/login-user.js +8 -8
- package/user/user.js +18 -4
- package/utils/backend-path.js +2 -2
- package/utils/index.js +4 -1
- package/websocket/repositories/websocket-connection-repository-documentdb.js +46 -21
- package/websocket/repositories/websocket-connection-repository-factory.js +4 -8
- package/websocket/repositories/websocket-connection-repository-mongo.js +26 -16
- package/websocket/repositories/websocket-connection-repository-postgres.js +26 -15
- package/websocket/repositories/websocket-connection-repository.js +26 -20
- package/websocket/websocket-message-sender-interface.js +38 -0
- package/database/adapters/lambda-invoker.js +0 -97
- package/database/repositories/migration-status-repository-s3.js +0 -137
- package/infrastructure/scheduler/eventbridge-scheduler-adapter.js +0 -184
package/syncs/sync.js
CHANGED
|
@@ -1,113 +1,117 @@
|
|
|
1
|
-
const md5 = require(
|
|
2
|
-
const { debug } = require(
|
|
3
|
-
const { get } = require(
|
|
1
|
+
const md5 = require('md5');
|
|
2
|
+
const { debug } = require('packages/logs');
|
|
3
|
+
const { get } = require('packages/assertions');
|
|
4
4
|
|
|
5
5
|
class Sync {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
this.
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
6
|
+
static Config = {
|
|
7
|
+
name: 'Sync',
|
|
8
|
+
|
|
9
|
+
// an array of keys we will use to form an object and then hash it. Order matters here
|
|
10
|
+
// because it will effect how the hash results
|
|
11
|
+
keys: [],
|
|
12
|
+
|
|
13
|
+
// matchOn is an array of keys that make the variable unique when combined together
|
|
14
|
+
// and is used to sync with the other objects
|
|
15
|
+
// matchOn keys _have_ to have a value, otherwise the object is not considered a match
|
|
16
|
+
matchOn: [],
|
|
17
|
+
|
|
18
|
+
// a key value mapping of module to then a list of keys that will map to
|
|
19
|
+
// an a function that takes in the module object and return the value from it
|
|
20
|
+
// format as follows:
|
|
21
|
+
// {
|
|
22
|
+
// ModuleName:{
|
|
23
|
+
// firstName:(moduleObject)=>{moduleObject['name'][0]},
|
|
24
|
+
// lastName:(moduleObject)=>{moduleObject['name'][1]},
|
|
25
|
+
// },
|
|
26
|
+
// ....
|
|
27
|
+
// }
|
|
28
|
+
moduleMap: {},
|
|
29
|
+
reverseModuleMap: {},
|
|
30
|
+
};
|
|
31
|
+
constructor(params) {
|
|
32
|
+
this.data = {};
|
|
33
|
+
|
|
34
|
+
let data = get(params, 'data');
|
|
35
|
+
this.moduleName = get(params, 'moduleName');
|
|
36
|
+
this.dataIdentifier = get(params, 'dataIdentifier');
|
|
37
|
+
this.useMapping = get(params, 'useMapping', true); // Use with caution...
|
|
38
|
+
|
|
39
|
+
this.dataIdentifierHash = this.constructor.hashJSON(
|
|
40
|
+
this.dataIdentifier
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
if (this.useMapping) {
|
|
44
|
+
for (let key of this.constructor.Config.keys) {
|
|
45
|
+
this.data[key] =
|
|
46
|
+
this.constructor.Config.moduleMap[this.moduleName][key](
|
|
47
|
+
data
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
} else {
|
|
51
|
+
this.data = data;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// matchHash is used to find matches between two sync objects
|
|
55
|
+
// Match data _has_ to have a value
|
|
56
|
+
const matchHashData = [];
|
|
57
|
+
this.missingMatchData = false;
|
|
58
|
+
for (const key of this.constructor.Config.matchOn) {
|
|
59
|
+
if (!this.data[key]) {
|
|
60
|
+
this.missingMatchData = true;
|
|
61
|
+
debug(`Data key of ${key} was missing from MatchOn`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
matchHashData.push(this.data[key]);
|
|
65
|
+
}
|
|
66
|
+
this.matchHash = this.constructor.hashJSON(matchHashData);
|
|
67
|
+
|
|
68
|
+
this.syncId = null;
|
|
48
69
|
}
|
|
49
70
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const matchHashData = [];
|
|
53
|
-
this.missingMatchData = false;
|
|
54
|
-
for (const key of this.constructor.Config.matchOn) {
|
|
55
|
-
if (!this.data[key]) {
|
|
56
|
-
this.missingMatchData = true;
|
|
57
|
-
debug(`Data key of ${key} was missing from MatchOn`);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
matchHashData.push(this.data[key]);
|
|
71
|
+
equals(syncObj) {
|
|
72
|
+
return this.matchHash === syncObj.matchHash;
|
|
61
73
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
this.syncId = null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
equals(syncObj) {
|
|
68
|
-
return this.matchHash === syncObj.matchHash;
|
|
69
|
-
}
|
|
70
|
-
dataKeyIsReplaceable(key) {
|
|
71
|
-
return this.data[key] === null || this.data[key] === "";
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
isModuleInMap(moduleName) {
|
|
75
|
-
return this.constructor.Config.moduleMap[name];
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
getName() {
|
|
79
|
-
return this.constructor.Config.name;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
getHashData(params) {
|
|
83
|
-
let omitEmptyStringsFromData = get(
|
|
84
|
-
params,
|
|
85
|
-
"omitEmptyStringsFromData",
|
|
86
|
-
false
|
|
87
|
-
);
|
|
88
|
-
let orderedData = [];
|
|
89
|
-
for (let key of this.constructor.Config.keys) {
|
|
90
|
-
if (omitEmptyStringsFromData && this.data[key] === "") {
|
|
91
|
-
this.data[key] = undefined;
|
|
92
|
-
}
|
|
93
|
-
orderedData.push(this.data[key]);
|
|
74
|
+
dataKeyIsReplaceable(key) {
|
|
75
|
+
return this.data[key] === null || this.data[key] === '';
|
|
94
76
|
}
|
|
95
77
|
|
|
96
|
-
|
|
97
|
-
|
|
78
|
+
isModuleInMap(moduleName) {
|
|
79
|
+
return this.constructor.Config.moduleMap[name];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
getName() {
|
|
83
|
+
return this.constructor.Config.name;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
getHashData(params) {
|
|
87
|
+
let omitEmptyStringsFromData = get(
|
|
88
|
+
params,
|
|
89
|
+
'omitEmptyStringsFromData',
|
|
90
|
+
false
|
|
91
|
+
);
|
|
92
|
+
let orderedData = [];
|
|
93
|
+
for (let key of this.constructor.Config.keys) {
|
|
94
|
+
if (omitEmptyStringsFromData && this.data[key] === '') {
|
|
95
|
+
this.data[key] = undefined;
|
|
96
|
+
}
|
|
97
|
+
orderedData.push(this.data[key]);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return this.constructor.hashJSON(orderedData);
|
|
101
|
+
}
|
|
98
102
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
setSyncId(syncId) {
|
|
104
|
+
this.syncId = syncId;
|
|
105
|
+
}
|
|
102
106
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
reverseModuleMap(moduleName) {
|
|
108
|
+
return this.constructor.Config.reverseModuleMap[moduleName](this.data);
|
|
109
|
+
}
|
|
106
110
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
+
static hashJSON(data) {
|
|
112
|
+
let dataString = JSON.stringify(data, null, 2);
|
|
113
|
+
return md5(dataString);
|
|
114
|
+
}
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
module.exports = Sync;
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
const { TokenRepositoryMongo } = require('./token-repository-mongo');
|
|
2
1
|
const { TokenRepositoryPostgres } = require('./token-repository-postgres');
|
|
3
|
-
const {
|
|
4
|
-
TokenRepositoryDocumentDB,
|
|
5
|
-
} = require('./token-repository-documentdb');
|
|
6
2
|
const config = require('../../database/config');
|
|
7
3
|
|
|
8
4
|
/**
|
|
@@ -16,12 +12,14 @@ function createTokenRepository() {
|
|
|
16
12
|
|
|
17
13
|
switch (dbType) {
|
|
18
14
|
case 'mongodb':
|
|
15
|
+
const { TokenRepositoryMongo } = require('./token-repository-mongo');
|
|
19
16
|
return new TokenRepositoryMongo();
|
|
20
17
|
|
|
21
18
|
case 'postgresql':
|
|
22
19
|
return new TokenRepositoryPostgres();
|
|
23
20
|
|
|
24
21
|
case 'documentdb':
|
|
22
|
+
const { TokenRepositoryDocumentDB } = require('./token-repository-documentdb');
|
|
25
23
|
return new TokenRepositoryDocumentDB();
|
|
26
24
|
|
|
27
25
|
default:
|
|
@@ -34,7 +32,7 @@ function createTokenRepository() {
|
|
|
34
32
|
module.exports = {
|
|
35
33
|
createTokenRepository,
|
|
36
34
|
// Export adapters for direct testing
|
|
37
|
-
TokenRepositoryMongo,
|
|
35
|
+
get TokenRepositoryMongo() { return require('./token-repository-mongo').TokenRepositoryMongo; },
|
|
38
36
|
TokenRepositoryPostgres,
|
|
39
|
-
TokenRepositoryDocumentDB,
|
|
37
|
+
get TokenRepositoryDocumentDB() { return require('./token-repository-documentdb').TokenRepositoryDocumentDB; },
|
|
40
38
|
};
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
declare module
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
export function get<TObject extends object, TKey extends keyof TObject>(
|
|
19
|
+
object: TObject,
|
|
20
|
+
key: TKey
|
|
21
|
+
): TObject[TKey];
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
export function getAll<TObject extends object, TKey extends keyof TObject>(
|
|
24
|
+
object: TObject,
|
|
25
|
+
requiredKeys: TKey[]
|
|
26
|
+
): Partial<TObject>;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
export function verifyType(value: unknown, paramType: TypeOfType): void;
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
41
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
47
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
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
59
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
65
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
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
71
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
83
|
}
|
package/types/core/index.d.ts
CHANGED
|
@@ -1,54 +1,99 @@
|
|
|
1
|
-
declare module
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
1
|
+
declare module '@friggframework/core' {
|
|
2
|
+
export class Delegate implements IFriggDelegate {
|
|
3
|
+
delegate: any;
|
|
4
|
+
delegateTypes: any[];
|
|
5
|
+
|
|
6
|
+
constructor(params: Record<string, unknown> & { delegate?: unknown });
|
|
7
|
+
notify(delegateString: string, object?: any): Promise<any>;
|
|
8
|
+
receiveNotification(
|
|
9
|
+
notifier: any,
|
|
10
|
+
delegateString: string,
|
|
11
|
+
object?: any
|
|
12
|
+
): Promise<any>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface IFriggDelegate {
|
|
16
|
+
delegate: any;
|
|
17
|
+
delegateTypes: any[];
|
|
18
|
+
|
|
19
|
+
notify(delegateString: string, object?: any): Promise<any>;
|
|
20
|
+
receiveNotification(
|
|
21
|
+
notifier: any,
|
|
22
|
+
delegateString: string,
|
|
23
|
+
object?: any
|
|
24
|
+
): Promise<any>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Interface for queue message operations (port in hexagonal architecture) */
|
|
28
|
+
export interface QueueClientInterface {
|
|
29
|
+
sendMessage(params: SendMessageParams): Promise<{ MessageId: string }>;
|
|
30
|
+
sendMessageBatch(params: SendMessageBatchParams): Promise<any>;
|
|
31
|
+
getQueueUrl(params: GetQueueURLParams): Promise<string>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export class Worker implements IWorker {
|
|
35
|
+
constructor(options?: { queueClient?: QueueClientInterface });
|
|
36
|
+
|
|
37
|
+
getQueueURL(params: GetQueueURLParams): Promise<string | undefined>;
|
|
38
|
+
|
|
39
|
+
run(params: { Records: any }): Promise<void>;
|
|
40
|
+
|
|
41
|
+
send(
|
|
42
|
+
params: object & { QueueUrl: any },
|
|
43
|
+
delay?: number
|
|
44
|
+
): Promise<string>;
|
|
45
|
+
|
|
46
|
+
sendAsyncSQSMessage(params: SendMessageParams): Promise<string>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
interface IWorker {
|
|
50
|
+
getQueueURL(params: GetQueueURLParams): Promise<string | undefined>;
|
|
51
|
+
run(params: { Records: any }): Promise<void>;
|
|
52
|
+
send(
|
|
53
|
+
params: object & { QueueUrl: any },
|
|
54
|
+
delay?: number
|
|
55
|
+
): Promise<string>;
|
|
56
|
+
sendAsyncSQSMessage(params: SendMessageParams): Promise<string>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function loadInstalledModules(): any[];
|
|
60
|
+
|
|
61
|
+
type GetQueueURLParams = {
|
|
62
|
+
QueueName: string;
|
|
63
|
+
QueueOwnerAWSAccountId?: string;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
type SendMessageParams = {
|
|
67
|
+
QueueUrl: string;
|
|
68
|
+
MessageBody: string;
|
|
69
|
+
DelaySeconds?: number;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
type SendMessageBatchParams = {
|
|
73
|
+
QueueUrl: string;
|
|
74
|
+
Entries: Array<{ Id: string; MessageBody: string }>;
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
/** Interface for envelope encryption key operations */
|
|
78
|
+
export class EncryptionKeyProviderInterface {
|
|
79
|
+
generateDataKey(): Promise<{
|
|
80
|
+
keyId: string;
|
|
81
|
+
encryptedKey: string;
|
|
82
|
+
plaintext: string | Buffer;
|
|
83
|
+
}>;
|
|
84
|
+
decryptDataKey(
|
|
85
|
+
keyId: string,
|
|
86
|
+
encryptedKey: string | Buffer
|
|
87
|
+
): Promise<string | Buffer>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/** Interface for WebSocket message sending */
|
|
91
|
+
export class WebSocketMessageSenderInterface {
|
|
92
|
+
send(connectionId: string, data: any, endpoint: string): Promise<void>;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export class StaleConnectionError extends Error {
|
|
96
|
+
connectionId: string;
|
|
97
|
+
constructor(connectionId: string);
|
|
98
|
+
}
|
|
54
99
|
}
|