mirror of https://github.com/Squidex/squidex.git
committed by
GitHub
16 changed files with 682 additions and 1078 deletions
File diff suppressed because it is too large
@ -1,15 +1,14 @@ |
|||||
{ |
{ |
||||
Data: { |
Data: { |
||||
Number: { |
Number: { |
||||
iv: 2 |
iv: 1 |
||||
}, |
|
||||
String: { |
|
||||
iv: test |
|
||||
} |
} |
||||
}, |
}, |
||||
|
NewStatus: , |
||||
Status: Published, |
Status: Published, |
||||
|
EditingStatus: Published, |
||||
Id: Guid_1, |
Id: Guid_1, |
||||
Version: 3, |
Version: 1, |
||||
_links: { |
_links: { |
||||
delete: { |
delete: { |
||||
Method: DELETE |
Method: DELETE |
||||
@ -1,20 +0,0 @@ |
|||||
{ |
|
||||
Data: {}, |
|
||||
Status: Published, |
|
||||
Id: Guid_1, |
|
||||
Version: 2, |
|
||||
_links: { |
|
||||
delete: { |
|
||||
Method: DELETE |
|
||||
}, |
|
||||
draft/create: { |
|
||||
Method: POST |
|
||||
}, |
|
||||
previous: { |
|
||||
Method: GET |
|
||||
}, |
|
||||
self: { |
|
||||
Method: GET |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,27 +0,0 @@ |
|||||
{ |
|
||||
Data: { |
|
||||
Number: { |
|
||||
iv: 2 |
|
||||
}, |
|
||||
String: { |
|
||||
iv: test |
|
||||
} |
|
||||
}, |
|
||||
Status: Published, |
|
||||
Id: Guid_1, |
|
||||
Version: 3, |
|
||||
_links: { |
|
||||
delete: { |
|
||||
Method: DELETE |
|
||||
}, |
|
||||
draft/create: { |
|
||||
Method: POST |
|
||||
}, |
|
||||
previous: { |
|
||||
Method: GET |
|
||||
}, |
|
||||
self: { |
|
||||
Method: GET |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,27 +0,0 @@ |
|||||
{ |
|
||||
Data: { |
|
||||
Number: { |
|
||||
iv: 2 |
|
||||
}, |
|
||||
String: { |
|
||||
iv: test |
|
||||
} |
|
||||
}, |
|
||||
Status: Published, |
|
||||
Id: Guid_1, |
|
||||
Version: 3, |
|
||||
_links: { |
|
||||
delete: { |
|
||||
Method: DELETE |
|
||||
}, |
|
||||
draft/create: { |
|
||||
Method: POST |
|
||||
}, |
|
||||
previous: { |
|
||||
Method: GET |
|
||||
}, |
|
||||
self: { |
|
||||
Method: GET |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,24 +0,0 @@ |
|||||
{ |
|
||||
Data: { |
|
||||
Id: { |
|
||||
iv: id2 |
|
||||
} |
|
||||
}, |
|
||||
Status: Published, |
|
||||
Id: Guid_1, |
|
||||
Version: 2, |
|
||||
_links: { |
|
||||
delete: { |
|
||||
Method: DELETE |
|
||||
}, |
|
||||
draft/create: { |
|
||||
Method: POST |
|
||||
}, |
|
||||
previous: { |
|
||||
Method: GET |
|
||||
}, |
|
||||
self: { |
|
||||
Method: GET |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,40 +0,0 @@ |
|||||
{ |
|
||||
Items: [ |
|
||||
{ |
|
||||
Data: { |
|
||||
Number: { |
|
||||
iv: 2 |
|
||||
} |
|
||||
}, |
|
||||
Status: Published, |
|
||||
Id: Guid_1, |
|
||||
Version: 4, |
|
||||
_links: { |
|
||||
delete: { |
|
||||
Method: DELETE |
|
||||
}, |
|
||||
draft/create: { |
|
||||
Method: POST |
|
||||
}, |
|
||||
previous: { |
|
||||
Method: GET |
|
||||
}, |
|
||||
self: { |
|
||||
Method: GET |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
], |
|
||||
Total: 1, |
|
||||
_links: { |
|
||||
create: { |
|
||||
Method: POST |
|
||||
}, |
|
||||
create/publish: { |
|
||||
Method: POST |
|
||||
}, |
|
||||
self: { |
|
||||
Method: GET |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,40 +0,0 @@ |
|||||
{ |
|
||||
Items: [ |
|
||||
{ |
|
||||
Data: { |
|
||||
Number: { |
|
||||
iv: 2 |
|
||||
} |
|
||||
}, |
|
||||
Status: Published, |
|
||||
Id: Guid_1, |
|
||||
Version: 1, |
|
||||
_links: { |
|
||||
delete: { |
|
||||
Method: DELETE |
|
||||
}, |
|
||||
draft/create: { |
|
||||
Method: POST |
|
||||
}, |
|
||||
previous: { |
|
||||
Method: GET |
|
||||
}, |
|
||||
self: { |
|
||||
Method: GET |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
], |
|
||||
Total: 1, |
|
||||
_links: { |
|
||||
create: { |
|
||||
Method: POST |
|
||||
}, |
|
||||
create/publish: { |
|
||||
Method: POST |
|
||||
}, |
|
||||
self: { |
|
||||
Method: GET |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,233 @@ |
|||||
|
// ==========================================================================
|
||||
|
// Squidex Headless CMS
|
||||
|
// ==========================================================================
|
||||
|
// Copyright (c) Squidex UG (haftungsbeschraenkt)
|
||||
|
// All rights reserved. Licensed under the MIT license.
|
||||
|
// ==========================================================================
|
||||
|
|
||||
|
using Squidex.ClientLibrary; |
||||
|
|
||||
|
namespace TestSuite; |
||||
|
|
||||
|
public static class Strategies |
||||
|
{ |
||||
|
public enum Deletion |
||||
|
{ |
||||
|
SingleSoft, |
||||
|
SinglePermanent, |
||||
|
BulkSoft, |
||||
|
BulkPermanent |
||||
|
} |
||||
|
|
||||
|
public static Task DeleteAsync(this ISquidexClientManager clientManager, ContentBase content, Deletion strategy) |
||||
|
{ |
||||
|
IContentsClient<MyContent, object> GetClient() |
||||
|
{ |
||||
|
return clientManager.CreateContentsClient<MyContent, object>(content.SchemaName); |
||||
|
} |
||||
|
|
||||
|
switch (strategy) |
||||
|
{ |
||||
|
case Deletion.SingleSoft: |
||||
|
return GetClient().DeleteAsync(content.Id); |
||||
|
case Deletion.SinglePermanent: |
||||
|
return GetClient().DeleteAsync(content.Id, new ContentDeleteOptions { Permanent = true }); |
||||
|
case Deletion.BulkSoft: |
||||
|
return GetClient().BulkUpdateAsync(new BulkUpdate |
||||
|
{ |
||||
|
Jobs = new List<BulkUpdateJob> |
||||
|
{ |
||||
|
new BulkUpdateJob |
||||
|
{ |
||||
|
Type = BulkUpdateType.Delete, |
||||
|
Id = content.Id, |
||||
|
Permanent = false, |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
case Deletion.BulkPermanent: |
||||
|
return GetClient().BulkUpdateAsync(new BulkUpdate |
||||
|
{ |
||||
|
Jobs = new List<BulkUpdateJob> |
||||
|
{ |
||||
|
new BulkUpdateJob |
||||
|
{ |
||||
|
Type = BulkUpdateType.Delete, |
||||
|
Id = content.Id, |
||||
|
Permanent = true, |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
default: |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public enum Update |
||||
|
{ |
||||
|
Normal, |
||||
|
Upsert, |
||||
|
UpsertBulk, |
||||
|
Bulk, |
||||
|
BulkWithSchema, |
||||
|
BulkShared |
||||
|
} |
||||
|
|
||||
|
public static Task UpdateAsync(this ISquidexClientManager clientManager, ContentBase content, object data, Update strategy) |
||||
|
{ |
||||
|
IContentsClient<MyContent, object> GetClient() |
||||
|
{ |
||||
|
return clientManager.CreateContentsClient<MyContent, object>(content.SchemaName); |
||||
|
} |
||||
|
|
||||
|
switch (strategy) |
||||
|
{ |
||||
|
case Update.Normal: |
||||
|
return GetClient().UpdateAsync(content.Id, data); |
||||
|
case Update.Upsert: |
||||
|
return GetClient().UpsertAsync(content.Id, data); |
||||
|
case Update.UpsertBulk: |
||||
|
return GetClient().BulkUpdateAsync(new BulkUpdate |
||||
|
{ |
||||
|
Jobs = new List<BulkUpdateJob> |
||||
|
{ |
||||
|
new BulkUpdateJob |
||||
|
{ |
||||
|
Id = content.Id, |
||||
|
Data = data, |
||||
|
Type = BulkUpdateType.Upsert |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
case Update.Bulk: |
||||
|
return GetClient().BulkUpdateAsync(new BulkUpdate |
||||
|
{ |
||||
|
Jobs = new List<BulkUpdateJob> |
||||
|
{ |
||||
|
new BulkUpdateJob |
||||
|
{ |
||||
|
Id = content.Id, |
||||
|
Data = data, |
||||
|
Type = BulkUpdateType.Update, |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
case Update.BulkWithSchema: |
||||
|
return GetClient().BulkUpdateAsync(new BulkUpdate |
||||
|
{ |
||||
|
Jobs = new List<BulkUpdateJob> |
||||
|
{ |
||||
|
new BulkUpdateJob |
||||
|
{ |
||||
|
Id = content.Id, |
||||
|
Data = data, |
||||
|
Type = BulkUpdateType.Update, |
||||
|
Schema = content.SchemaName |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
case Update.BulkShared: |
||||
|
return clientManager.CreateSharedContentsClient<MyContent, object>().BulkUpdateAsync(new BulkUpdate |
||||
|
{ |
||||
|
Jobs = new List<BulkUpdateJob> |
||||
|
{ |
||||
|
new BulkUpdateJob |
||||
|
{ |
||||
|
Id = content.Id, |
||||
|
Data = data, |
||||
|
Type = BulkUpdateType.Update, |
||||
|
Schema = content.SchemaName |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
default: |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public enum Patch |
||||
|
{ |
||||
|
Normal, |
||||
|
Upsert, |
||||
|
Bulk, |
||||
|
BulkWithSchema, |
||||
|
BulkShared, |
||||
|
UpsertBulk |
||||
|
} |
||||
|
|
||||
|
public static Task PatchAsync(this ISquidexClientManager clientManager, ContentBase content, object data, Patch strategy) |
||||
|
{ |
||||
|
IContentsClient<MyContent, object> GetClient() |
||||
|
{ |
||||
|
return clientManager.CreateContentsClient<MyContent, object>(content.SchemaName); |
||||
|
} |
||||
|
|
||||
|
switch (strategy) |
||||
|
{ |
||||
|
case Patch.Normal: |
||||
|
return GetClient().PatchAsync(content.Id, data); |
||||
|
case Patch.Upsert: |
||||
|
return GetClient().UpsertAsync(content.Id, data, ContentUpsertOptions.AsPatch); |
||||
|
case Patch.UpsertBulk: |
||||
|
return GetClient().BulkUpdateAsync(new BulkUpdate |
||||
|
{ |
||||
|
Jobs = new List<BulkUpdateJob> |
||||
|
{ |
||||
|
new BulkUpdateJob |
||||
|
{ |
||||
|
Id = content.Id, |
||||
|
Data = data, |
||||
|
Patch = true, |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
case Patch.Bulk: |
||||
|
return GetClient().BulkUpdateAsync(new BulkUpdate |
||||
|
{ |
||||
|
Jobs = new List<BulkUpdateJob> |
||||
|
{ |
||||
|
new BulkUpdateJob |
||||
|
{ |
||||
|
Id = content.Id, |
||||
|
Data = data, |
||||
|
Type = BulkUpdateType.Patch |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
case Patch.BulkWithSchema: |
||||
|
return GetClient().BulkUpdateAsync(new BulkUpdate |
||||
|
{ |
||||
|
Jobs = new List<BulkUpdateJob> |
||||
|
{ |
||||
|
new BulkUpdateJob |
||||
|
{ |
||||
|
Id = content.Id, |
||||
|
Data = data, |
||||
|
Type = BulkUpdateType.Patch, |
||||
|
Schema = content.SchemaName |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
case Patch.BulkShared: |
||||
|
return clientManager.CreateSharedContentsClient<MyContent, object>().BulkUpdateAsync(new BulkUpdate |
||||
|
{ |
||||
|
Jobs = new List<BulkUpdateJob> |
||||
|
{ |
||||
|
new BulkUpdateJob |
||||
|
{ |
||||
|
Id = content.Id, |
||||
|
Data = data, |
||||
|
Type = BulkUpdateType.Patch, |
||||
|
Schema = content.SchemaName |
||||
|
} |
||||
|
} |
||||
|
}); |
||||
|
default: |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private class MyContent : Content<object> |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue