@friggframework/core 2.0.0--canary.702.ef0dc8c.0 → 2.0.0--canary.710.7cfcf12.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 (29) hide show
  1. package/CLAUDE.md +41 -1
  2. package/application/commands/README.md +17 -11
  3. package/application/commands/entity-commands.js +18 -60
  4. package/application/commands/integration-commands.js +63 -0
  5. package/database/documentdb-encryption-service.js +2 -33
  6. package/database/encryption/README.md +3 -3
  7. package/database/encryption/ciphertext-format.js +24 -0
  8. package/database/encryption/encryption-schema-registry.js +109 -29
  9. package/database/encryption/field-encryption-service.js +13 -16
  10. package/database/prisma.js +10 -1
  11. package/handlers/app-definition-loader.js +2 -9
  12. package/integrations/repositories/integration-repository-documentdb.js +32 -0
  13. package/integrations/repositories/integration-repository-interface.js +30 -0
  14. package/integrations/repositories/integration-repository-mongo.js +52 -0
  15. package/integrations/repositories/integration-repository-postgres.js +58 -0
  16. package/integrations/use-cases/add-entities-to-integration.js +92 -0
  17. package/integrations/use-cases/create-integration.js +57 -19
  18. package/integrations/use-cases/remove-entities-from-integration.js +70 -0
  19. package/integrations/utils/assert-entity-ids-input.js +42 -0
  20. package/jest-setup.js +13 -2
  21. package/jest-teardown.js +5 -2
  22. package/jest.config.js +4 -0
  23. package/jest.db.config.js +23 -0
  24. package/modules/utils/map-module-dto.js +5 -3
  25. package/modules/utils/to-credential-id.js +14 -0
  26. package/package.json +8 -8
  27. package/queues/queuer-util.js +6 -5
  28. package/user/tests/doubles/test-user-repository.js +1 -1
  29. package/user/use-cases/get-user-from-bearer-token.js +7 -2
package/package.json CHANGED
@@ -1,18 +1,16 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
- "description": "",
4
3
  "prettier": "@friggframework/prettier-config",
5
- "version": "2.0.0--canary.702.ef0dc8c.0",
4
+ "version": "2.0.0--canary.710.7cfcf12.0",
6
5
  "dependencies": {
7
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
8
7
  "@aws-sdk/client-kms": "^3.588.0",
9
8
  "@aws-sdk/client-lambda": "^3.714.0",
10
9
  "@aws-sdk/client-s3": "^3.588.0",
11
- "@aws-sdk/client-scheduler": "^3.1153.0",
10
+ "@aws-sdk/client-scheduler": "^3.588.0",
12
11
  "@aws-sdk/client-sqs": "^3.588.0",
13
12
  "@aws-sdk/client-ssm": "^3.588.0",
14
13
  "@aws-sdk/s3-request-presigner": "^3.588.0",
15
- "@friggframework/schemas": "2.0.0--canary.702.ef0dc8c.0",
16
14
  "@hapi/boom": "^10.0.1",
17
15
  "@opentelemetry/api": "^1.9.1",
18
16
  "@opentelemetry/context-async-hooks": "^2.9.0",
@@ -50,9 +48,9 @@
50
48
  }
51
49
  },
52
50
  "devDependencies": {
53
- "@friggframework/eslint-config": "2.0.0--canary.702.ef0dc8c.0",
54
- "@friggframework/prettier-config": "2.0.0--canary.702.ef0dc8c.0",
55
- "@friggframework/test": "2.0.0--canary.702.ef0dc8c.0",
51
+ "@friggframework/eslint-config": "2.0.0--canary.710.7cfcf12.0",
52
+ "@friggframework/prettier-config": "2.0.0--canary.710.7cfcf12.0",
53
+ "@friggframework/test": "2.0.0--canary.710.7cfcf12.0",
56
54
  "@prisma/client": "^6.19.3",
57
55
  "@types/lodash": "4.17.15",
58
56
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -70,6 +68,7 @@
70
68
  "scripts": {
71
69
  "lint:fix": "prettier --write --loglevel error . && eslint . --fix",
72
70
  "test": "jest --passWithNoTests # TODO",
71
+ "test:db": "jest --config jest.db.config.js --runInBand",
73
72
  "prisma:generate:mongo": "npx prisma generate --schema ./prisma-mongodb/schema.prisma",
74
73
  "prisma:generate:postgres": "npx prisma generate --schema ./prisma-postgresql/schema.prisma",
75
74
  "prisma:generate": "npm run prisma:generate:mongo && npm run prisma:generate:postgres",
@@ -88,8 +87,9 @@
88
87
  "url": "https://github.com/friggframework/frigg/issues"
89
88
  },
90
89
  "homepage": "https://github.com/friggframework/frigg#readme",
90
+ "description": "",
91
91
  "publishConfig": {
92
92
  "access": "public"
93
93
  },
94
- "gitHead": "ef0dc8cb6c6f56048a61b6759faad7322046925d"
94
+ "gitHead": "7cfcf1267a412053163b99b7f9a123f7e4e1bde3"
95
95
  }
@@ -97,16 +97,17 @@ const QueuerUtil = {
97
97
  Id: uuid(),
98
98
  MessageBody: JSON.stringify(entry),
99
99
  });
100
- // Sends 10, then purges the buffer
100
+ // Sends 10, then starts a fresh buffer. Each command gets its own
101
+ // array: clearing the shared buffer in place would also empty the
102
+ // Entries of a command that was already sent.
101
103
  if (buffer.length === batchSize) {
104
+ const batch = buffer.splice(0, buffer.length);
102
105
  const command = new SendMessageBatchCommand({
103
- Entries: buffer,
106
+ Entries: batch,
104
107
  QueueUrl: queueUrl,
105
108
  });
106
109
  const result = await sqs.send(command);
107
- inspectBatchResult(result, queueUrl, buffer);
108
- // Purge the buffer
109
- buffer.splice(0, buffer.length);
110
+ inspectBatchResult(result, queueUrl, batch);
110
111
  }
111
112
  }
112
113
 
@@ -23,7 +23,7 @@ class TestUserRepository {
23
23
 
24
24
  async createToken(userId, rawToken, minutes = 120) {
25
25
  const token = `token-for-${userId}-for-${minutes}-mins`;
26
- this.tokens.set(token, { user: userId, rawToken });
26
+ this.tokens.set(token, { id: token, userId, rawToken });
27
27
  return token;
28
28
  }
29
29
 
@@ -40,8 +40,13 @@ class GetUserFromBearerToken {
40
40
  throw Boom.unauthorized('Session Token Not Found');
41
41
  }
42
42
 
43
+ const tokenUserId = sessionToken.userId;
44
+ if (!tokenUserId) {
45
+ throw Boom.unauthorized('Session Token Has No User');
46
+ }
47
+
43
48
  if (this.userConfig.primary === 'organization') {
44
- const organizationUserData = await this.userRepository.findOrganizationUserById(sessionToken.user);
49
+ const organizationUserData = await this.userRepository.findOrganizationUserById(tokenUserId);
45
50
 
46
51
  if (!organizationUserData) {
47
52
  throw Boom.unauthorized('Organization User Not Found');
@@ -57,7 +62,7 @@ class GetUserFromBearerToken {
57
62
  );
58
63
  }
59
64
 
60
- const individualUserData = await this.userRepository.findIndividualUserById(sessionToken.user);
65
+ const individualUserData = await this.userRepository.findIndividualUserById(tokenUserId);
61
66
 
62
67
  if (!individualUserData) {
63
68
  throw Boom.unauthorized('Individual User Not Found');