1- import webflow from "../../webflow .app.mjs" ;
1+ import app from "../../webflow_v2 .app.mjs" ;
22
33export default {
4- key : "webflow -create-collection-item" ,
4+ key : "webflow_v2 -create-collection-item" ,
55 name : "Create Collection Item" ,
66 description : "Create new collection item. [See the docs here](https://developers.webflow.com/#create-new-collection-item)" ,
7- version : "0.1.7 " ,
7+ version : "0.0.{{ts}} " ,
88 type : "action" ,
99 props : {
10- webflow ,
10+ app ,
1111 siteId : {
1212 propDefinition : [
13- webflow ,
13+ app ,
1414 "sites" ,
1515 ] ,
1616 } ,
1717 collectionId : {
1818 propDefinition : [
19- webflow ,
19+ app ,
2020 "collections" ,
2121 ( c ) => ( {
2222 siteId : c . siteId ,
2323 } ) ,
2424 ] ,
2525 reloadProps : true ,
2626 } ,
27- live : {
28- label : "Live" ,
29- description : "Indicate if the item should be published to the live site" ,
30- type : "boolean" ,
31- default : false ,
32- } ,
3327 } ,
3428 async additionalProps ( ) {
3529 const props = { } ;
3630 if ( ! this . collectionId ) {
3731 return props ;
3832 }
39- const { fields } = await this . webflow . getCollection ( this . collectionId ) ;
33+ const { fields } = await this . app . getCollection ( this . collectionId ) ;
4034 for ( const field of fields ) {
41- if ( field . editable && field . slug !== "_archived " && field . slug !== "_draft " ) {
35+ if ( field . editable && field . slug !== "isArchived " && field . slug !== "isDraft " ) {
4236 props [ field . slug ] = {
4337 type : "string" ,
4438 label : field . name ,
@@ -55,29 +49,23 @@ export default {
5549 } ,
5650 async run ( { $ } ) {
5751 const {
58- webflow ,
52+ app ,
5953 // eslint-disable-next-line no-unused-vars
6054 siteId,
61- // eslint-disable-next-line no-unused-vars
6255 collectionId,
63- live,
6456 ...fields
6557 } = this ;
6658
67- const webflowClient = webflow . _createApiClient ( ) ;
68-
69- const response = await webflowClient . createItem ( {
70- collectionId : this . collectionId ,
71- fields : {
59+ const response = await app . createCollectionItem ( {
60+ collectionId,
61+ fieldData : {
7262 ...fields ,
73- _archived : false ,
74- _draft : false ,
63+ isArchived : false ,
64+ isDraft : false ,
7565 } ,
76- } , {
77- live,
7866 } ) ;
7967
80- $ . export ( "$summary" , `Successfully created collection item ${ fields . name } ` ) ;
68+ $ . export ( "$summary" , `Successfully created collection item ${ fields . name ?? "" } ` ) ;
8169
8270 return response ;
8371 } ,
0 commit comments