@friggframework/core 2.0.0--canary.528.da2ff89.0 → 2.0.0--canary.529.8aea052.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.
@@ -77,7 +77,10 @@ class CredentialRepositoryDocumentDB extends CredentialRepositoryInterface {
77
77
  const { identifiers, details } = credentialDetails;
78
78
  if (!identifiers)
79
79
  throw new Error('identifiers required to upsert credential');
80
- if (!identifiers.userId) {
80
+ // Support both 'userId' (new) and 'user' (legacy) field names.
81
+ // All 49 API modules in api-module-library use 'user' in identifiers.
82
+ // The database column is 'userId', so we map 'user' → 'userId' here.
83
+ if (!identifiers.userId && !identifiers.user) {
81
84
  throw new Error('userId required in identifiers');
82
85
  }
83
86
  if (!identifiers.externalId) {
@@ -143,7 +146,8 @@ class CredentialRepositoryDocumentDB extends CredentialRepositoryInterface {
143
146
  }
144
147
 
145
148
  const plainDocument = {
146
- userId: toObjectId(identifiers.userId),
149
+ // Map legacy 'user' field to 'userId' column
150
+ userId: toObjectId(identifiers.userId || identifiers.user),
147
151
  externalId: identifiers.externalId,
148
152
  authIsValid: details.authIsValid,
149
153
  data: { ...oauthData },
@@ -244,8 +248,11 @@ class CredentialRepositoryDocumentDB extends CredentialRepositoryInterface {
244
248
  const idObj = toObjectId(identifiers._id || identifiers.id);
245
249
  if (idObj) filter._id = idObj;
246
250
  }
251
+ // Support both 'userId' (new) and 'user' (legacy) field names
247
252
  if (identifiers.userId) {
248
253
  filter.userId = toObjectId(identifiers.userId);
254
+ } else if (identifiers.user) {
255
+ filter.userId = toObjectId(identifiers.user);
249
256
  }
250
257
  if (identifiers.externalId !== undefined) {
251
258
  filter.externalId = identifiers.externalId;
@@ -96,7 +96,10 @@ class CredentialRepositoryMongo extends CredentialRepositoryInterface {
96
96
  if (!identifiers)
97
97
  throw new Error('identifiers required to upsert credential');
98
98
 
99
- if (!identifiers.userId) {
99
+ // Support both 'userId' (new) and 'user' (legacy) field names.
100
+ // All 49 API modules in api-module-library use 'user' in identifiers.
101
+ // The database column is 'userId', so we map 'user' → 'userId' here.
102
+ if (!identifiers.userId && !identifiers.user) {
100
103
  throw new Error('userId required in identifiers');
101
104
  }
102
105
  if (!identifiers.externalId) {
@@ -137,7 +140,8 @@ class CredentialRepositoryMongo extends CredentialRepositoryInterface {
137
140
 
138
141
  const created = await this.prisma.credential.create({
139
142
  data: {
140
- userId: identifiers.userId,
143
+ // Map legacy 'user' field to 'userId' column
144
+ userId: identifiers.userId || identifiers.user,
141
145
  externalId: identifiers.externalId,
142
146
  authIsValid: authIsValid,
143
147
  data: oauthData,
@@ -242,7 +246,9 @@ class CredentialRepositoryMongo extends CredentialRepositoryInterface {
242
246
 
243
247
  if (identifiers._id) where.id = identifiers._id;
244
248
  if (identifiers.id) where.id = identifiers.id;
249
+ // Support both 'userId' (new) and 'user' (legacy) field names
245
250
  if (identifiers.userId) where.userId = identifiers.userId;
251
+ else if (identifiers.user) where.userId = identifiers.user;
246
252
  if (identifiers.externalId) where.externalId = identifiers.externalId;
247
253
 
248
254
  return where;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@friggframework/core",
3
3
  "prettier": "@friggframework/prettier-config",
4
- "version": "2.0.0--canary.528.da2ff89.0",
4
+ "version": "2.0.0--canary.529.8aea052.0",
5
5
  "dependencies": {
6
6
  "@aws-sdk/client-apigatewaymanagementapi": "^3.588.0",
7
7
  "@aws-sdk/client-kms": "^3.588.0",
@@ -38,9 +38,9 @@
38
38
  }
39
39
  },
40
40
  "devDependencies": {
41
- "@friggframework/eslint-config": "2.0.0--canary.528.da2ff89.0",
42
- "@friggframework/prettier-config": "2.0.0--canary.528.da2ff89.0",
43
- "@friggframework/test": "2.0.0--canary.528.da2ff89.0",
41
+ "@friggframework/eslint-config": "2.0.0--canary.529.8aea052.0",
42
+ "@friggframework/prettier-config": "2.0.0--canary.529.8aea052.0",
43
+ "@friggframework/test": "2.0.0--canary.529.8aea052.0",
44
44
  "@prisma/client": "^6.17.0",
45
45
  "@types/lodash": "4.17.15",
46
46
  "@typescript-eslint/eslint-plugin": "^8.0.0",
@@ -80,5 +80,5 @@
80
80
  "publishConfig": {
81
81
  "access": "public"
82
82
  },
83
- "gitHead": "da2ff89dfe0eb3cdf49147180d4382329ba22e26"
83
+ "gitHead": "8aea052a7a48529be341f734d93f43468821974d"
84
84
  }