velocious 1.0.673 → 1.0.674
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/build/frontend-model-controller.js +10 -2
- package/build/frontend-model-resource/base-resource.js +21 -2
- package/build/src/frontend-model-controller.d.ts +5 -0
- package/build/src/frontend-model-controller.d.ts.map +1 -1
- package/build/src/frontend-model-controller.js +10 -3
- package/build/src/frontend-model-resource/base-resource.d.ts +10 -0
- package/build/src/frontend-model-resource/base-resource.d.ts.map +1 -1
- package/build/src/frontend-model-resource/base-resource.js +19 -3
- package/package.json +1 -1
- package/src/frontend-model-controller.js +10 -2
- package/src/frontend-model-resource/base-resource.js +21 -2
package/package.json
CHANGED
|
@@ -1060,6 +1060,14 @@ export default class FrontendModelController extends Controller {
|
|
|
1060
1060
|
return this.frontendModelResourceInstance().primaryKey()
|
|
1061
1061
|
}
|
|
1062
1062
|
|
|
1063
|
+
/**
|
|
1064
|
+
* Runs frontend model database primary key.
|
|
1065
|
+
* @returns {import("./utils/model-primary-key.js").ModelPrimaryKeyDefinition} - Primary key resolved to database-queryable attribute names.
|
|
1066
|
+
*/
|
|
1067
|
+
frontendModelDatabasePrimaryKey() {
|
|
1068
|
+
return this.frontendModelResourceInstance().databasePrimaryKey()
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1063
1071
|
/**
|
|
1064
1072
|
* Runs frontend model ability action.
|
|
1065
1073
|
* @param {"index" | "find" | "create" | "update" | "destroy" | "attach" | "attachmentList" | "download" | "url"} action - Frontend action.
|
|
@@ -1138,7 +1146,7 @@ export default class FrontendModelController extends Controller {
|
|
|
1138
1146
|
* @returns {import("./utils/model-primary-key.js").ModelPrimaryKeyValue} - Primary key value.
|
|
1139
1147
|
*/
|
|
1140
1148
|
frontendModelPrimaryKeyValue(model) {
|
|
1141
|
-
const primaryKey = this.
|
|
1149
|
+
const primaryKey = this.frontendModelDatabasePrimaryKey()
|
|
1142
1150
|
|
|
1143
1151
|
return readModelPrimaryKeyValue(primaryKey, (attributeName) => model.readAttribute(attributeName))
|
|
1144
1152
|
}
|
|
@@ -1194,7 +1202,7 @@ export default class FrontendModelController extends Controller {
|
|
|
1194
1202
|
async frontendModelFilterAuthorizedModels({action, models}) {
|
|
1195
1203
|
if (models.length === 0) return models
|
|
1196
1204
|
|
|
1197
|
-
const primaryKey = this.
|
|
1205
|
+
const primaryKey = this.frontendModelDatabasePrimaryKey()
|
|
1198
1206
|
|
|
1199
1207
|
const identities = models.map((model) => this.frontendModelPrimaryKeyValue(model))
|
|
1200
1208
|
const authorizedIds = await this.frontendModelAuthorizedIdentitySet({
|
|
@@ -699,7 +699,7 @@ export default class FrontendModelBaseResource extends AuthorizationBaseResource
|
|
|
699
699
|
? ModelClass.accessibleFor(this.syncAbilityAction(forDelete ? "destroy" : "update"), ability)
|
|
700
700
|
: ModelClass.where({})
|
|
701
701
|
|
|
702
|
-
return await query.findBy(modelPrimaryKeyConditions(this.
|
|
702
|
+
return await query.findBy(modelPrimaryKeyConditions(this.databasePrimaryKey(), mutation.resourceId))
|
|
703
703
|
}
|
|
704
704
|
|
|
705
705
|
/**
|
|
@@ -894,6 +894,25 @@ export default class FrontendModelBaseResource extends AuthorizationBaseResource
|
|
|
894
894
|
return ResourceClass.resolvedPrimaryKey(this.resourceConfiguration())
|
|
895
895
|
}
|
|
896
896
|
|
|
897
|
+
/**
|
|
898
|
+
* Runs database primary key.
|
|
899
|
+
*
|
|
900
|
+
* Declared scalar resource primary keys are client-facing aliases (for example
|
|
901
|
+
* a camelCase name for a legacy raw-column primary key). Database-facing identity
|
|
902
|
+
* operations must resolve the alias to the model's canonical attribute so where
|
|
903
|
+
* and pluck clauses hit real columns, while client-facing payloads keep the alias.
|
|
904
|
+
* @returns {import("../utils/model-primary-key.js").ModelPrimaryKeyDefinition} - Primary key resolved to database-queryable attribute names.
|
|
905
|
+
*/
|
|
906
|
+
databasePrimaryKey() {
|
|
907
|
+
const primaryKey = this.primaryKey()
|
|
908
|
+
|
|
909
|
+
if (Array.isArray(primaryKey)) return primaryKey
|
|
910
|
+
|
|
911
|
+
const modelClass = this.databaseModelClass()
|
|
912
|
+
|
|
913
|
+
return modelClass.resolveAttributeName(primaryKey) || primaryKey
|
|
914
|
+
}
|
|
915
|
+
|
|
897
916
|
/**
|
|
898
917
|
* Runs authorized query.
|
|
899
918
|
* @param {FrontendModelResourceAction} action - Ability action.
|
|
@@ -1027,7 +1046,7 @@ export default class FrontendModelBaseResource extends AuthorizationBaseResource
|
|
|
1027
1046
|
query = query.preload(preload)
|
|
1028
1047
|
}
|
|
1029
1048
|
|
|
1030
|
-
return await query.findBy(modelPrimaryKeyConditions(this.
|
|
1049
|
+
return await query.findBy(modelPrimaryKeyConditions(this.databasePrimaryKey(), id))
|
|
1031
1050
|
}
|
|
1032
1051
|
|
|
1033
1052
|
/**
|