private async Task <NamedId <Guid> > CreateEducationSchemaAsync(Func <ICommand, Task> publish)
        {
            var command = new CreateSchema
            {
                Name       = "education",
                Properties = new SchemaProperties
                {
                    Label = "Education"
                },
                Fields = new List <CreateSchemaField>
                {
                    new CreateSchemaField
                    {
                        Name       = "degree",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = true,
                            IsListField = true,
                            Label       = "Degree",
                            Hints       = "The degree you got or achieved"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "school",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = true,
                            IsListField = true,
                            Label       = "School",
                            Hints       = "The school or university"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "logo",
                        Properties = new AssetsFieldProperties
                        {
                            IsRequired  = false,
                            IsListField = false,
                            MustBeImage = true,
                            Label       = "Logo",
                            Hints       = "The logo of the school"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "from",
                        Properties = new DateTimeFieldProperties
                        {
                            Editor      = DateTimeFieldEditor.Date,
                            IsRequired  = true,
                            IsListField = false,
                            Label       = "Start Date",
                            Hints       = "The start date"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "to",
                        Properties = new DateTimeFieldProperties
                        {
                            Editor      = DateTimeFieldEditor.Date,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "End Date",
                            Hints       = "The end date, keep empty if you still study there"
                        }
                    }
                },
                Publish = true
            };

            await publish(command);

            return(NamedId.Of(command.SchemaId, command.Name));
        }
예제 #2
0
        public Task AddTargetAsync(Guid ruleId, NamedId <Guid> appId, int limits, int?numDays)
        {
            UpdateTarget(ruleId, t => { t.Limits = limits; t.AppId = appId; t.NumDays = numDays; });

            return(state.WriteAsync());
        }
예제 #3
0
 protected override void WriteValue(JsonWriter writer, NamedId <long> value, JsonSerializer serializer)
 {
     writer.WriteValue($"{value.Id},{value.Name}");
 }
예제 #4
0
 public string ContentsUI(NamedId <DomainId> appId, NamedId <DomainId> schemaId)
 {
     throw new NotSupportedException();
 }
예제 #5
0
 public string DashboardUI(NamedId <DomainId> appId)
 {
     throw new NotSupportedException();
 }
예제 #6
0
 public string?AssetSource(NamedId <DomainId> appId, DomainId assetId, long fileVersion)
 {
     return($"assets/source/{assetId}");
 }
예제 #7
0
 public string ContentUI(NamedId <DomainId> appId, NamedId <DomainId> schemaId, DomainId contentId)
 {
     return($"contents/{schemaId.Name}/{contentId}");
 }
 private static IEnrichedContentEntity CreateRefContent(Guid id, int version, string name, int number, NamedId <Guid> schemaId)
 {
     return(new ContentEntity
     {
         Id = id,
         DataDraft =
             new NamedContentData()
             .AddField("name",
                       new ContentFieldData()
                       .AddValue("iv", name))
             .AddField("number",
                       new ContentFieldData()
                       .AddValue("iv", number)),
         SchemaId = schemaId,
         Version = version
     });
 }
예제 #9
0
 public void Create(CreateSchema command)
 {
     RaiseEvent(command, new SchemaCreated {
         SchemaId = NamedId.Of(command.SchemaId, command.Name), Schema = command.BuildSchema()
     });
 }
        private static Task CreateApiResourcesSchemaAsync(Func <ICommand, Task> publish, NamedId <DomainId> scopeId)
        {
            var schema =
                SchemaBuilder.Create("API Resources")
                .AddString("Name", f => f
                           .Unique()
                           .Required()
                           .ShowInList()
                           .Hints("The unique name of the API."))
                .AddString("Display Name", f => f
                           .Localizable()
                           .Hints("The display name of the API."))
                .AddString("Description", f => f
                           .Localizable()
                           .Hints("The description name of the API."))
                .AddBoolean("Disabled", f => f
                            .AsToggle()
                            .Hints("Enable or disable the API."))
                .AddReferences("Scopes", f => f
                               .WithSchemaId(scopeId.Id)
                               .Hints("The scopes for this API."))
                .AddTags("User Claims", f => f
                         .Hints("List of accociated user claims that should be included when this resource is requested."))
                .Build();

            return(publish(schema));
        }
예제 #11
0
        public Task ExecuteAsync(NamedId <Guid> appId, NamedId <Guid> schemaId, params IndexCommand[] commands)
        {
            var index = grainFactory.GetGrain <ILuceneTextIndexGrain>(appId.Id);

            return(index.IndexAsync(schemaId, commands.AsImmutable()));
        }
예제 #12
0
파일: SchemaGrain.cs 프로젝트: zxbe/squidex
 private NamedId <long> CreateFieldId(AddField command)
 {
     return(NamedId.Of(Snapshot.TotalFields + 1L, command.Name));
 }
        private async Task <NamedId <Guid> > CreateBasicsSchemaAsync(Func <ICommand, Task> publish)
        {
            var command = new CreateSchema
            {
                Name       = "basics",
                Properties = new SchemaProperties
                {
                    Label = "Basics"
                },
                Fields = new List <CreateSchemaField>
                {
                    new CreateSchemaField
                    {
                        Name       = "firstName",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = true,
                            IsListField = true,
                            Label       = "First Name",
                            Hints       = "Your first name"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "lastName",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = true,
                            IsListField = true,
                            Label       = "Last Name",
                            Hints       = "Your last name"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "profession",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.TextArea,
                            IsRequired  = true,
                            IsListField = false,
                            Label       = "Profession",
                            Hints       = "Define your profession"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "image",
                        Properties = new AssetsFieldProperties
                        {
                            IsRequired  = false,
                            IsListField = false,
                            MustBeImage = true,
                            Label       = "Image",
                            Hints       = "Your image"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "summary",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.TextArea,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "Summary",
                            Hints       = "Write a short summary about yourself"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "githubLink",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "Github",
                            Hints       = "An optional link to your Github account"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "blogLink",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "Blog",
                            Hints       = "An optional link to your blog"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "twitterLink",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "Twitter",
                            Hints       = "An optional link to your twitter account"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "linkedInLink",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "LinkedIn",
                            Hints       = "An optional link to your LinkedIn account"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "emailAddress",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "Email Address",
                            Hints       = "An optional email address to contact you"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "legalTerms",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.TextArea,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "Legal terms",
                            Hints       = "The terms to fulfill legal requirements"
                        }
                    }
                },
                Publish = true
            };

            await publish(command);

            return(NamedId.Of(command.SchemaId, command.Name));
        }
        private async Task <NamedId <Guid> > CreatePublicationsSchemaAsync(Func <ICommand, Task> publish)
        {
            var command = new CreateSchema
            {
                Name       = "publications",
                Properties = new SchemaProperties
                {
                    Label = "Publications"
                },
                Fields = new List <CreateSchemaField>
                {
                    new CreateSchemaField
                    {
                        Name       = "name",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = true,
                            IsListField = true,
                            Label       = "Name",
                            Hints       = "The name or title of your publication"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "description",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.TextArea,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "Description",
                            Hints       = "Describe the content of your publication"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "cover",
                        Properties = new AssetsFieldProperties
                        {
                            IsRequired  = true,
                            IsListField = false,
                            MustBeImage = true,
                            Label       = "Cover",
                            Hints       = "The cover of your publication"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "link",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "Link",
                            Hints       = "An optional link to your publication"
                        }
                    }
                },
                Publish = true
            };

            await publish(command);

            return(NamedId.Of(command.SchemaId, command.Name));
        }
 private static bool MatchsSchema(ContentChangedTriggerSchemaV2 schema, NamedId <DomainId> eventId)
 {
     return(eventId.Id == schema.SchemaId);
 }
예제 #16
0
 private NamedId <long> CreateFieldId(AddField command)
 {
     return(NamedId.Of(Snapshot.SchemaFieldsTotal + 1, command.Name));
 }
예제 #17
0
 public string?AssetThumbnail(NamedId <DomainId> appId, string idOrSlug, AssetType assetType)
 {
     return($"assets/{appId.Name}/{idOrSlug}?width=100");
 }
예제 #18
0
 private static AppLanguageAdded CreateInitialLanguage(NamedId <Guid> id)
 {
     return(new AppLanguageAdded {
         AppId = id, Language = DefaultLanguage
     });
 }
예제 #19
0
 public string AssetContent(NamedId <DomainId> appId, string idOrSlug)
 {
     return($"assets/{appId.Name}/{idOrSlug}");
 }
예제 #20
0
 private static AppContributorAssigned CreateInitialOwner(NamedId <Guid> id, SquidexCommand command)
 {
     return(new AppContributorAssigned {
         AppId = id, ContributorId = command.Actor.Identifier, Permission = AppContributorPermission.Owner
     });
 }
예제 #21
0
 public string AssetsUI(NamedId <DomainId> appId, string? @ref = null)
 {
     throw new NotSupportedException();
 }
예제 #22
0
 private ISchemaEntity CreateSchema(string name, SchemaType type = SchemaType.Default)
 {
     return(Mocks.Schema(appId, NamedId.Of(DomainId.NewGuid(), name), new Schema(name, type: type)));
 }
예제 #23
0
 public string ContributorsUI(NamedId <DomainId> appId)
 {
     throw new NotSupportedException();
 }
예제 #24
0
        // Constructors.

        public DescriptorBase(NamedId id)
        {
            this.id = id;
        }
예제 #25
0
 public string RolesUI(NamedId <DomainId> appId)
 {
     throw new NotSupportedException();
 }
        public async Task Should_make_permission_check_with_schema_feature()
        {
            actionExecutingContext.HttpContext.Features.Set <IAppFeature>(new AppFeature(NamedId.Of(DomainId.NewGuid(), "my-app")));
            actionExecutingContext.HttpContext.Features.Set <ISchemaFeature>(new SchemaFeature(NamedId.Of(DomainId.NewGuid(), "my-schema")));

            user.AddClaim(new Claim(SquidexClaimTypes.Permissions, "squidex.apps.my-app.schemas.my-schema"));

            SetContext();

            var sut = new ApiPermissionAttribute(Permissions.AppSchemasUpdate);

            await sut.OnActionExecutionAsync(actionExecutingContext, next);

            Assert.Null(actionExecutingContext.Result);
            Assert.True(isNextCalled);
        }
예제 #27
0
 protected override void WriteValue(JsonWriter writer, NamedId <Guid> value, JsonSerializer serializer)
 {
     writer.WriteValue(value.ToString());
 }
        public async Task Should_return_forbidden_when_user_has_wrong_permission()
        {
            actionExecutingContext.HttpContext.Features.Set <IAppFeature>(new AppFeature(NamedId.Of(DomainId.NewGuid(), "my-app")));

            user.AddClaim(new Claim(SquidexClaimTypes.Permissions, "squidex.apps.other-app"));

            SetContext();

            var sut = new ApiPermissionAttribute(Permissions.AppSchemasCreate);

            await sut.OnActionExecutionAsync(actionExecutingContext, next);

            Assert.Equal(403, (actionExecutingContext.Result as StatusCodeResult)?.StatusCode);
            Assert.False(isNextCalled);
        }
예제 #29
0
 public Task <IChangePlanResult> ChangePlanAsync(string userId, NamedId <DomainId> appId, string?planId, string?referer)
 {
     return(Task.FromResult <IChangePlanResult>(new PlanChangedResult()));
 }
        private async Task <NamedId <Guid> > CreateExperienceSchemaAsync(Func <ICommand, Task> publish)
        {
            var command = new CreateSchema
            {
                Name       = "experience",
                Properties = new SchemaProperties
                {
                    Label = "Experience"
                },
                Fields = new List <CreateSchemaField>
                {
                    new CreateSchemaField
                    {
                        Name       = "position",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = true,
                            IsListField = true,
                            Label       = "Position",
                            Hints       = "Your position in this job"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "company",
                        Properties = new StringFieldProperties
                        {
                            Editor      = StringFieldEditor.Input,
                            IsRequired  = true,
                            IsListField = true,
                            Label       = "Company",
                            Hints       = "The company or organization you worked for"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "logo",
                        Properties = new AssetsFieldProperties
                        {
                            IsRequired  = false,
                            IsListField = false,
                            MustBeImage = true,
                            Label       = "Logo",
                            Hints       = "The logo of the company or organization you worked for"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "from",
                        Properties = new DateTimeFieldProperties
                        {
                            Editor      = DateTimeFieldEditor.Date,
                            IsRequired  = true,
                            IsListField = false,
                            Label       = "Start Date",
                            Hints       = "The start date"
                        }
                    },
                    new CreateSchemaField
                    {
                        Name       = "to",
                        Properties = new DateTimeFieldProperties
                        {
                            Editor      = DateTimeFieldEditor.Date,
                            IsRequired  = false,
                            IsListField = false,
                            Label       = "End Date",
                            Hints       = "The end date, keep empty if you still work there"
                        }
                    }
                },
                Publish = true
            };

            await publish(command);

            return(NamedId.Of(command.SchemaId, command.Name));
        }