@nascentdigital/funnel-cms 4.4.17 → 4.4.19
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.
|
@@ -91,7 +91,7 @@ export declare namespace CollectionClient {
|
|
|
91
91
|
}
|
|
92
92
|
type Update = {
|
|
93
93
|
id: Schema.Collection.Id;
|
|
94
|
-
|
|
94
|
+
updatedOn: number;
|
|
95
95
|
updates: ReadonlyArray<Schema.Collection.Update>;
|
|
96
96
|
};
|
|
97
97
|
namespace Replace {
|
|
@@ -159,7 +159,11 @@ export declare namespace CollectionClient {
|
|
|
159
159
|
}
|
|
160
160
|
namespace Update {
|
|
161
161
|
type Args = Update;
|
|
162
|
-
type Result =
|
|
162
|
+
type Result = {
|
|
163
|
+
updatedOn: number;
|
|
164
|
+
changeSetId: Schema.ChangeSet.Id;
|
|
165
|
+
collection?: Schema.Collection.Data;
|
|
166
|
+
};
|
|
163
167
|
}
|
|
164
168
|
namespace Unpublish {
|
|
165
169
|
type Args = Schema.Collection.Id;
|
|
@@ -30,7 +30,7 @@ export declare namespace IStrapiContentClient {
|
|
|
30
30
|
method?: 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
|
|
31
31
|
onError?: Callback<TError>;
|
|
32
32
|
};
|
|
33
|
-
type CustomCommand = 'changeset/query' | 'changeset/commit' | 'changeset/revert' | 'page/update' | 'query/pages' | 'query/rank-pages' | 'query/collections' | 'query/collection' | 'publish' | 'unpublish' | 'version';
|
|
33
|
+
type CustomCommand = 'changeset/query' | 'changeset/commit' | 'changeset/revert' | 'page/update' | 'collection/update' | 'query/pages' | 'query/rank-pages' | 'query/collections' | 'query/collection' | 'publish' | 'unpublish' | 'version';
|
|
34
34
|
type UnpublishErrorData = Jsonify<{
|
|
35
35
|
error: true;
|
|
36
36
|
pageRefs: PageData.Ref[];
|
|
@@ -10,7 +10,7 @@ export declare class StrapiCollectionClient implements CollectionClient {
|
|
|
10
10
|
get({ version, id }: CollectionClient.Get.Args): Promise<CollectionClient.Get.Result>;
|
|
11
11
|
create(args: CollectionClient.Create.Args): Promise<CollectionClient.Create.Result>;
|
|
12
12
|
duplicate({ source: collectionId, targetCollection, targetLanguage }: CollectionClient.Duplicate.Args): Promise<CollectionClient.Duplicate.Result>;
|
|
13
|
-
update(
|
|
13
|
+
update(args: CollectionClient.Update.Args): Promise<CollectionClient.Update.Result>;
|
|
14
14
|
replace({ updatedCollection, version, skipSync }: CollectionClient.Replace.Args): Promise<CollectionClient.Replace.Result>;
|
|
15
15
|
unpublish(collectionId: CollectionClient.Unpublish.Args): Promise<CollectionClient.Unpublish.Result>;
|
|
16
16
|
getDependants({ id: collectionId, version }: CollectionClient.GetDependants.Args): Promise<CollectionClient.GetDependants.Result>;
|
|
@@ -397,61 +397,12 @@ class StrapiCollectionClient {
|
|
|
397
397
|
throw funnel_core_1.IsometricErrorUtils.coerceError(e);
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
async update(
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
if (!user) {
|
|
406
|
-
throw new funnel_core_1.NotAuthenticatedError();
|
|
407
|
-
}
|
|
408
|
-
// get latest version of collection
|
|
409
|
-
const entries = client.collection('collections');
|
|
410
|
-
const resultProps = funnel_core_1.Schema.Collection.Data.Props.all;
|
|
411
|
-
const { data: currentData } = await entries.findOne(collectionId, {
|
|
412
|
-
status: 'draft',
|
|
413
|
-
populate: serialization_1.CollectionData.populate
|
|
414
|
-
});
|
|
415
|
-
// TODO: validate collection is able to be updated (e.g. not archived, etc.)
|
|
416
|
-
// TODO: switch to isometric error so we can catch it on client-side
|
|
417
|
-
// throw if collection doesn't exist
|
|
418
|
-
if (!currentData) {
|
|
419
|
-
throw new funnel_core_1.NotFoundError();
|
|
420
|
-
}
|
|
421
|
-
// deserialize collection (we'll be updating this version)
|
|
422
|
-
const collection = serialization_1.CollectionData.deserialize(currentData, strapiUrl, resultProps);
|
|
423
|
-
// set errors
|
|
424
|
-
collection.errors = errors;
|
|
425
|
-
console.debug(`[StrapiPageClient/update] applying ${updates.length} collection updates`);
|
|
426
|
-
// merge changes (the original collection will have changed)
|
|
427
|
-
const model = funnel_core_1.Schema.CollectionModel.from(collection);
|
|
428
|
-
model.update(updates);
|
|
429
|
-
console.debug(`[StrapiPageClient/update] saving updated collection`);
|
|
430
|
-
// resolve change set (rebind)
|
|
431
|
-
const { provider } = this;
|
|
432
|
-
const changeSet = await provider.changeSets.resolve({ id: collection.changeSetId, fallbackToGlobal: true });
|
|
433
|
-
collection.changeSetId = changeSet.id;
|
|
434
|
-
// save collection
|
|
435
|
-
const update = serialization_1.CollectionData.serialize(collection);
|
|
436
|
-
const { data: updatedData } = await entries.update(collection.id, Object.assign(Object.assign({}, update), { state: 'draft' }), {
|
|
437
|
-
status: 'draft',
|
|
438
|
-
populate: serialization_1.CollectionData.populate
|
|
439
|
-
});
|
|
440
|
-
// update changeset
|
|
441
|
-
changeSet.addCollectionChange(user.id, {
|
|
442
|
-
__type: 'collection',
|
|
443
|
-
id: collection.id,
|
|
444
|
-
groupId: collection.groupId,
|
|
445
|
-
name: collection.name,
|
|
446
|
-
schema: collection.type,
|
|
447
|
-
language: collection.language,
|
|
448
|
-
type: collection.publishedOn ? 'update' : 'create',
|
|
449
|
-
errors: collection.errors
|
|
400
|
+
async update(args) {
|
|
401
|
+
return this.provider.customRequest({
|
|
402
|
+
command: 'collection/update',
|
|
403
|
+
method: 'POST',
|
|
404
|
+
data: JSON.stringify(args)
|
|
450
405
|
});
|
|
451
|
-
provider.changeSets.update(changeSet.toData())
|
|
452
|
-
.catch(console.error);
|
|
453
|
-
// return collection
|
|
454
|
-
return serialization_1.CollectionData.deserialize(updatedData, strapiUrl, resultProps);
|
|
455
406
|
}
|
|
456
407
|
async replace({ updatedCollection, version, skipSync }) {
|
|
457
408
|
console.debug(`[StrapiCollectionClient/replace] replacing collection`);
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nascentdigital/funnel-cms",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.19",
|
|
4
4
|
"repository": {
|
|
5
5
|
"url": "git+https://github.com/nascentdigital/funnel.git",
|
|
6
6
|
"directory": "libs/cms"
|
|
7
7
|
},
|
|
8
8
|
"publishConfig": {
|
|
9
|
-
"registry": "https://registry.npmjs.org/"
|
|
9
|
+
"registry": "https://registry.npmjs.org/",
|
|
10
|
+
"access": "public"
|
|
10
11
|
},
|
|
11
12
|
"main": "dist/index.js",
|
|
12
13
|
"types": "dist/index.d.ts",
|
|
@@ -41,5 +42,5 @@
|
|
|
41
42
|
"ts-jest": "^29",
|
|
42
43
|
"type-fest": "^4"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "d4ab7346c7b2e39897e5eb6be0a64e2f0278d51b"
|
|
45
46
|
}
|