From 6536377979d690a46bc56638a0c69b03cc2290b1 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Wed, 18 Oct 2023 09:21:36 -0700 Subject: [PATCH 1/4] docs: better xmldoc comment for security attributes --- .../Api/Behaviors/StandardBehaviors`1.cs | 2 +- .../DataAnnotations/CreateAttribute.cs | 7 +++++-- .../DataAnnotations/DeleteAttribute.cs | 7 +++++-- .../DataAnnotations/EditAttribute.cs | 12 ++++++++++-- .../DataAnnotations/ReadAttribute.cs | 11 +++++++++-- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/IntelliTect.Coalesce/Api/Behaviors/StandardBehaviors`1.cs b/src/IntelliTect.Coalesce/Api/Behaviors/StandardBehaviors`1.cs index a1fe0fe7e..e371ef943 100644 --- a/src/IntelliTect.Coalesce/Api/Behaviors/StandardBehaviors`1.cs +++ b/src/IntelliTect.Coalesce/Api/Behaviors/StandardBehaviors`1.cs @@ -162,7 +162,7 @@ IDataSourceParameters parameters /// /// Maps the incoming DTO's properties to the item that will be saved to the database. /// - /// Descriminator between a create and a update operation. + /// Discriminator between a create and a update operation. /// The item that will be saved to the database. /// The incoming item from the client. /// The additional parameters sent by the client. diff --git a/src/IntelliTect.Coalesce/DataAnnotations/CreateAttribute.cs b/src/IntelliTect.Coalesce/DataAnnotations/CreateAttribute.cs index 92b54265f..0ac262ff3 100644 --- a/src/IntelliTect.Coalesce/DataAnnotations/CreateAttribute.cs +++ b/src/IntelliTect.Coalesce/DataAnnotations/CreateAttribute.cs @@ -4,8 +4,11 @@ namespace IntelliTect.Coalesce.DataAnnotations { /// - /// Should users be allowed to create an entity via the API/button. - /// + /// + /// When placed on an entity or custom class exposed by Coalesce, + /// controls the permissions for saving new instances of the model via the /save or /bulkSave endpoints. + /// + /// [AttributeUsage(AttributeTargets.Class)] public sealed class CreateAttribute : SecurityAttribute { diff --git a/src/IntelliTect.Coalesce/DataAnnotations/DeleteAttribute.cs b/src/IntelliTect.Coalesce/DataAnnotations/DeleteAttribute.cs index 044276a23..15c4053e0 100644 --- a/src/IntelliTect.Coalesce/DataAnnotations/DeleteAttribute.cs +++ b/src/IntelliTect.Coalesce/DataAnnotations/DeleteAttribute.cs @@ -4,8 +4,11 @@ namespace IntelliTect.Coalesce.DataAnnotations { /// - /// Should users be allowed to delete an entity via the API/button. - /// + /// + /// When placed on an entity or custom class exposed by Coalesce, + /// controls the permissions for the deleting existing instances of the model via the /delete or /bulkSave endpoints. + /// + /// [AttributeUsage(AttributeTargets.Class)] public class DeleteAttribute : SecurityAttribute { diff --git a/src/IntelliTect.Coalesce/DataAnnotations/EditAttribute.cs b/src/IntelliTect.Coalesce/DataAnnotations/EditAttribute.cs index 600ee8023..9b4718d64 100644 --- a/src/IntelliTect.Coalesce/DataAnnotations/EditAttribute.cs +++ b/src/IntelliTect.Coalesce/DataAnnotations/EditAttribute.cs @@ -4,10 +4,18 @@ namespace IntelliTect.Coalesce.DataAnnotations { /// - /// The Class or Property is read/write for the users and groups and not accessible to others. + /// + /// When placed on an entity or custom class exposed by Coalesce, + /// controls the permissions for modifying existing instances of the model via the /save or /bulkSave endpoints. + /// + /// + /// When placed on a property exposed by Coalesce, controls the roles that are allowed + /// to send data from the client to the server for that property for any purpose, + /// including the /save and /bulkSave APIs, and method parameters. + /// /// [AttributeUsage(AttributeTargets.Property | AttributeTargets.Class)] - public class EditAttribute: SecurityAttribute + public class EditAttribute : SecurityAttribute { public EditAttribute() { diff --git a/src/IntelliTect.Coalesce/DataAnnotations/ReadAttribute.cs b/src/IntelliTect.Coalesce/DataAnnotations/ReadAttribute.cs index ff78bc6f4..425acdc37 100644 --- a/src/IntelliTect.Coalesce/DataAnnotations/ReadAttribute.cs +++ b/src/IntelliTect.Coalesce/DataAnnotations/ReadAttribute.cs @@ -3,10 +3,17 @@ namespace IntelliTect.Coalesce.DataAnnotations { + /// /// - /// The Class or Property is read only for the users and groups and not accessible to others. - /// If no roles are specified, the target is readable by anyone. + /// When placed on an entity or custom class exposed by Coalesce, + /// controls the permissions for fetching existing instances of the model from + /// the /get, /list, and /count endpoints. + /// + /// + /// When placed on a property exposed by Coalesce, controls the roles that are allowed + /// to read data from that property for any usage of the parent model, + /// including when the model is a custom method result or a nested child of another model. /// /// If specified on a property with no , the property is read-only. /// From 6c432d07f9d9b1f9da32217d3458383992f05942 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Wed, 18 Oct 2023 18:46:05 -0700 Subject: [PATCH 2/4] fix(vue2): participate in RefUnwrapBailTypes --- src/coalesce-vue/src/api-client.ts | 7 +++++++ src/coalesce-vue/src/viewmodel.ts | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/src/coalesce-vue/src/api-client.ts b/src/coalesce-vue/src/api-client.ts index 147e1f3da..88879617a 100644 --- a/src/coalesce-vue/src/api-client.ts +++ b/src/coalesce-vue/src/api-client.ts @@ -2007,3 +2007,10 @@ declare module "@vue/reactivity" { coalesceApiModels: ApiState | ApiClient; } } + +// The vue2 version of this interface: +declare module "vue" { + export interface RefUnwrapBailTypes { + coalesceApiModels: ApiState | ApiClient; + } +} diff --git a/src/coalesce-vue/src/viewmodel.ts b/src/coalesce-vue/src/viewmodel.ts index ea582ea10..e49c2af40 100644 --- a/src/coalesce-vue/src/viewmodel.ts +++ b/src/coalesce-vue/src/viewmodel.ts @@ -2219,3 +2219,10 @@ declare module "@vue/reactivity" { coalesceViewModels: ViewModel | ListViewModel | ServiceViewModel; } } + +// The vue2 version of this interface: +declare module "vue" { + export interface RefUnwrapBailTypes { + coalesceViewModels: ViewModel | ListViewModel | ServiceViewModel; + } +} From 856bcd353e307d8d7c2b5c3244c67c8a75ae0d12 Mon Sep 17 00:00:00 2001 From: Andrew Scott Date: Fri, 20 Oct 2023 16:19:15 -0700 Subject: [PATCH 3/4] fix: update classes in c-select to reflect classes used by latest vuetify --- .../src/components/input/c-select.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/coalesce-vue-vuetify3/src/components/input/c-select.vue b/src/coalesce-vue-vuetify3/src/components/input/c-select.vue index 6eee55cbf..2c22ef9fd 100644 --- a/src/coalesce-vue-vuetify3/src/components/input/c-select.vue +++ b/src/coalesce-vue-vuetify3/src/components/input/c-select.vue @@ -36,11 +36,14 @@ :item="internalModelValue" :search="search" > - - - - - + + + + + Date: Fri, 20 Oct 2023 18:23:18 -0700 Subject: [PATCH 4/4] fix: correctly parse "Z" offset specifier in parseJSONDate --- src/coalesce-vue/src/util.ts | 10 +++++----- src/coalesce-vue/test/model.toModel.spec.ts | 10 ++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/coalesce-vue/src/util.ts b/src/coalesce-vue/src/util.ts index 3d7a1d73c..aa957e508 100644 --- a/src/coalesce-vue/src/util.ts +++ b/src/coalesce-vue/src/util.ts @@ -44,7 +44,7 @@ export function isNullOrWhitespace(value: string | null | undefined) { } const iso8601DateRegex = - /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?)?/; + /^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:(Z)|(.)(\d{2}):?(\d{2})?)?)?/; const iso8601TimeRegex = /^(\d{2}):(\d{2}):(\d{2})(?:\.(\d{0,7}))?(?:Z|(.)(\d{2}):?(\d{2})?)?$/; @@ -90,17 +90,17 @@ export function parseJSONDate(argument: string, kind: DateKind = "datetime") { var parts = argument.match(iso8601DateRegex) || []; - const part9 = parts[9]; // TZ offset + const partTzOffset = parts[8] == "Z" ? 0 : parts[10]; // TZ offset - if (part9 !== undefined) { + if (partTzOffset !== undefined) { // Date+Time, with offset specifier return new Date( Date.UTC( +parts[1], +parts[2] - 1, +parts[3], - +parts[4] - (+part9 || 0) * (parts[8] == "-" ? -1 : 1), - +parts[5] - (+parts[10] || 0) * (parts[8] == "-" ? -1 : 1), + +parts[4] - (+partTzOffset || 0) * (parts[9] == "-" ? -1 : 1), + +parts[5] - (+parts[11] || 0) * (parts[9] == "-" ? -1 : 1), +parts[6], +((parts[7] || "0") + "00").substring(0, 3) ) diff --git a/src/coalesce-vue/test/model.toModel.spec.ts b/src/coalesce-vue/test/model.toModel.spec.ts index ab9a0a8fd..0381ed46f 100644 --- a/src/coalesce-vue/test/model.toModel.spec.ts +++ b/src/coalesce-vue/test/model.toModel.spec.ts @@ -75,6 +75,11 @@ const dtoToModelMappings = [ dto: "2020-06-10T21:00:00+00:00", model: new Date(1591822800000), }, + { + meta: studentProps.birthDate, + dto: "2020-06-10T21:00:00-00:30", + model: new Date(1591824600000), + }, { // Dates without timezone should be assumed to be local time. meta: studentProps.birthDate, @@ -86,6 +91,11 @@ const dtoToModelMappings = [ dto: "2020-06-10", model: new Date(2020, 5, 10, 0, 0, 0, 0), }, + { + meta: { ...studentProps.birthDate, dateKind: "date" }, + dto: "2020-06-10T14:00:00Z", + model: new Date(1591797600000), + }, { meta: { ...studentProps.birthDate, dateKind: "time" }, dto: "12:34:56",