@@ -98,4 +98,366 @@ describe('reverseSafeSchema()', function () {
9898 } ) ;
9999 } ) ;
100100 } ) ;
101+
102+ describe ( 'when giving some real life schema' , function ( ) {
103+ it ( 'should return the correct object' , function ( ) {
104+ // --- GIVEN
105+ const schemaInput = [
106+ {
107+ id : 'n8nWorkflow.credentials.0.createdAt:string' ,
108+ } ,
109+ {
110+ id : 'n8nWorkflow.credentials.0.data.accessToken:string' ,
111+ } ,
112+ {
113+ id : 'n8nWorkflow.credentials.0.id:string' ,
114+ } ,
115+ {
116+ id : 'n8nWorkflow.credentials.0.isManaged:bool' ,
117+ } ,
118+ {
119+ id : 'n8nWorkflow.credentials.0.name:string' ,
120+ } ,
121+ {
122+ id : 'n8nWorkflow.credentials.0.type:string' ,
123+ } ,
124+ {
125+ id : 'n8nWorkflow.credentials.0.updatedAt:string' ,
126+ } ,
127+ {
128+ id : 'n8nWorkflow.workflows.0.active:bool' ,
129+ } ,
130+ {
131+ id : 'n8nWorkflow.workflows.0.connections.Date___Time.main.0.0.index:f64' ,
132+ } ,
133+ {
134+ id : 'n8nWorkflow.workflows.0.connections.Date___Time.main.0.0.node:string' ,
135+ } ,
136+ {
137+ id : 'n8nWorkflow.workflows.0.connections.Date___Time.main.0.0.type:string' ,
138+ } ,
139+ {
140+ id : 'n8nWorkflow.workflows.0.connections.Schedule_Trigger.main.0.0.index:f64' ,
141+ } ,
142+ {
143+ id : 'n8nWorkflow.workflows.0.connections.Schedule_Trigger.main.0.0.node:string' ,
144+ } ,
145+ {
146+ id : 'n8nWorkflow.workflows.0.connections.Schedule_Trigger.main.0.0.type:string' ,
147+ } ,
148+ {
149+ id : 'n8nWorkflow.workflows.0.connections.When_clicking__Execute_workflow_.main.0.0.index:f64' ,
150+ } ,
151+ {
152+ id : 'n8nWorkflow.workflows.0.connections.When_clicking__Execute_workflow_.main.0.0.node:string' ,
153+ } ,
154+ {
155+ id : 'n8nWorkflow.workflows.0.connections.When_clicking__Execute_workflow_.main.0.0.type:string' ,
156+ } ,
157+ {
158+ id : 'n8nWorkflow.workflows.0.createdAt:string' ,
159+ } ,
160+ {
161+ id : 'n8nWorkflow.workflows.0.id:string' ,
162+ } ,
163+ {
164+ id : 'n8nWorkflow.workflows.0.isArchived:bool' ,
165+ } ,
166+ {
167+ id : 'n8nWorkflow.workflows.0.meta.templateCredsSetupCompleted:bool' ,
168+ } ,
169+ {
170+ id : 'n8nWorkflow.workflows.0.name:string' ,
171+ } ,
172+ {
173+ id : 'n8nWorkflow.workflows.0.nodes.0.credentials.slackApi.id:string' ,
174+ } ,
175+ {
176+ id : 'n8nWorkflow.workflows.0.nodes.0.credentials.slackApi.name:string' ,
177+ } ,
178+ {
179+ id : 'n8nWorkflow.workflows.0.nodes.0.id:string' ,
180+ } ,
181+ {
182+ id : 'n8nWorkflow.workflows.0.nodes.0.name:string' ,
183+ } ,
184+ {
185+ id : 'n8nWorkflow.workflows.0.nodes.0.parameters.channelId.__rl:bool' ,
186+ } ,
187+ {
188+ id : 'n8nWorkflow.workflows.0.nodes.0.parameters.channelId.mode:string' ,
189+ } ,
190+ {
191+ id : 'n8nWorkflow.workflows.0.nodes.0.parameters.channelId.value:string' ,
192+ } ,
193+ {
194+ id : 'n8nWorkflow.workflows.0.nodes.0.parameters.otherOptions.includeLinkToWorkflow:bool' ,
195+ } ,
196+ {
197+ id : 'n8nWorkflow.workflows.0.nodes.0.parameters.select:string' ,
198+ } ,
199+ {
200+ id : 'n8nWorkflow.workflows.0.nodes.0.parameters.text:string' ,
201+ } ,
202+ {
203+ id : 'n8nWorkflow.workflows.0.nodes.0.position.0:f64' ,
204+ } ,
205+ {
206+ id : 'n8nWorkflow.workflows.0.nodes.0.position.1:f64' ,
207+ } ,
208+ {
209+ id : 'n8nWorkflow.workflows.0.nodes.0.type:string' ,
210+ } ,
211+ {
212+ id : 'n8nWorkflow.workflows.0.nodes.0.typeVersion:f64' ,
213+ } ,
214+ {
215+ id : 'n8nWorkflow.workflows.0.nodes.0.webhookId:string' ,
216+ } ,
217+ {
218+ id : 'n8nWorkflow.workflows.0.nodes.1.id:string' ,
219+ } ,
220+ {
221+ id : 'n8nWorkflow.workflows.0.nodes.1.name:string' ,
222+ } ,
223+ {
224+ id : 'n8nWorkflow.workflows.0.nodes.1.parameters.customFormat:string' ,
225+ } ,
226+ {
227+ id : 'n8nWorkflow.workflows.0.nodes.1.parameters.date:string' ,
228+ } ,
229+ {
230+ id : 'n8nWorkflow.workflows.0.nodes.1.parameters.format:string' ,
231+ } ,
232+ {
233+ id : 'n8nWorkflow.workflows.0.nodes.1.parameters.operation:string' ,
234+ } ,
235+ {
236+ id : 'n8nWorkflow.workflows.0.nodes.1.position.0:f64' ,
237+ } ,
238+ {
239+ id : 'n8nWorkflow.workflows.0.nodes.1.position.1:f64' ,
240+ } ,
241+ {
242+ id : 'n8nWorkflow.workflows.0.nodes.1.type:string' ,
243+ } ,
244+ {
245+ id : 'n8nWorkflow.workflows.0.nodes.1.typeVersion:f64' ,
246+ } ,
247+ {
248+ id : 'n8nWorkflow.workflows.0.nodes.2.id:string' ,
249+ } ,
250+ {
251+ id : 'n8nWorkflow.workflows.0.nodes.2.name:string' ,
252+ } ,
253+ {
254+ id : 'n8nWorkflow.workflows.0.nodes.2.parameters.rule.interval.0.field:string' ,
255+ } ,
256+ {
257+ id : 'n8nWorkflow.workflows.0.nodes.2.parameters.rule.interval.0.minutesInterval:f64' ,
258+ } ,
259+ {
260+ id : 'n8nWorkflow.workflows.0.nodes.2.position.0:f64' ,
261+ } ,
262+ {
263+ id : 'n8nWorkflow.workflows.0.nodes.2.position.1:f64' ,
264+ } ,
265+ {
266+ id : 'n8nWorkflow.workflows.0.nodes.2.type:string' ,
267+ } ,
268+ {
269+ id : 'n8nWorkflow.workflows.0.nodes.2.typeVersion:f64' ,
270+ } ,
271+ {
272+ id : 'n8nWorkflow.workflows.0.nodes.3.id:string' ,
273+ } ,
274+ {
275+ id : 'n8nWorkflow.workflows.0.nodes.3.name:string' ,
276+ } ,
277+ {
278+ id : 'n8nWorkflow.workflows.0.nodes.3.position.0:f64' ,
279+ } ,
280+ {
281+ id : 'n8nWorkflow.workflows.0.nodes.3.position.1:f64' ,
282+ } ,
283+ {
284+ id : 'n8nWorkflow.workflows.0.nodes.3.type:string' ,
285+ } ,
286+ {
287+ id : 'n8nWorkflow.workflows.0.nodes.3.typeVersion:f64' ,
288+ } ,
289+ {
290+ id : 'n8nWorkflow.workflows.0.settings.callerPolicy:string' ,
291+ } ,
292+ {
293+ id : 'n8nWorkflow.workflows.0.settings.executionOrder:string' ,
294+ } ,
295+ {
296+ id : 'n8nWorkflow.workflows.0.settings.timezone:string' ,
297+ } ,
298+ {
299+ id : 'n8nWorkflow.workflows.0.triggerCount:f64' ,
300+ } ,
301+ {
302+ id : 'n8nWorkflow.workflows.0.updatedAt:string' ,
303+ } ,
304+ {
305+ id : 'n8nWorkflow.workflows.0.versionId:string' ,
306+ } ,
307+ ] ;
308+ // --- WHEN
309+ const safeSchema = reverseSafeSchema ( schemaInput ) ;
310+
311+ // --- THEN
312+ expect ( safeSchema ) . toEqual ( {
313+ n8nWorkflow : {
314+ credentials : {
315+ '0' : {
316+ createdAt : 'string' ,
317+ updatedAt : 'string' ,
318+ id : 'string' ,
319+ name : 'string' ,
320+ data : {
321+ accessToken : 'string' ,
322+ } ,
323+ type : 'string' ,
324+ isManaged : false ,
325+ } ,
326+ } ,
327+ workflows : {
328+ '0' : {
329+ createdAt : 'string' ,
330+ updatedAt : 'string' ,
331+ id : 'string' ,
332+ name : 'string' ,
333+ active : false ,
334+ isArchived : false ,
335+ nodes : {
336+ '0' : {
337+ parameters : {
338+ select : 'string' ,
339+ channelId : {
340+ __rl : false ,
341+ value : 'string' ,
342+ mode : 'string' ,
343+ } ,
344+ text : 'string' ,
345+ otherOptions : {
346+ includeLinkToWorkflow : false ,
347+ } ,
348+ } ,
349+ type : 'string' ,
350+ typeVersion : 1 ,
351+ position : {
352+ '0' : 1 ,
353+ '1' : 1 ,
354+ } ,
355+ id : 'string' ,
356+ name : 'string' ,
357+ webhookId : 'string' ,
358+ credentials : {
359+ slackApi : {
360+ id : 'string' ,
361+ name : 'string' ,
362+ } ,
363+ } ,
364+ } ,
365+ '1' : {
366+ parameters : {
367+ operation : 'string' ,
368+ date : 'string' ,
369+ format : 'string' ,
370+ customFormat : 'string' ,
371+ } ,
372+ type : 'string' ,
373+ typeVersion : 1 ,
374+ position : {
375+ '0' : 1 ,
376+ '1' : 1 ,
377+ } ,
378+ id : 'string' ,
379+ name : 'string' ,
380+ } ,
381+ '2' : {
382+ parameters : {
383+ rule : {
384+ interval : {
385+ '0' : {
386+ field : 'string' ,
387+ minutesInterval : 1 ,
388+ } ,
389+ } ,
390+ } ,
391+ } ,
392+ type : 'string' ,
393+ typeVersion : 1 ,
394+ position : {
395+ '0' : 1 ,
396+ '1' : 1 ,
397+ } ,
398+ id : 'string' ,
399+ name : 'string' ,
400+ } ,
401+ '3' : {
402+ type : 'string' ,
403+ typeVersion : 1 ,
404+ position : {
405+ '0' : 1 ,
406+ '1' : 1 ,
407+ } ,
408+ id : 'string' ,
409+ name : 'string' ,
410+ } ,
411+ } ,
412+ connections : {
413+ Date___Time : {
414+ main : {
415+ '0' : {
416+ '0' : {
417+ node : 'string' ,
418+ type : 'string' ,
419+ index : 1 ,
420+ } ,
421+ } ,
422+ } ,
423+ } ,
424+ Schedule_Trigger : {
425+ main : {
426+ '0' : {
427+ '0' : {
428+ node : 'string' ,
429+ type : 'string' ,
430+ index : 1 ,
431+ } ,
432+ } ,
433+ } ,
434+ } ,
435+ When_clicking__Execute_workflow_ : {
436+ main : {
437+ '0' : {
438+ '0' : {
439+ node : 'string' ,
440+ type : 'string' ,
441+ index : 1 ,
442+ } ,
443+ } ,
444+ } ,
445+ } ,
446+ } ,
447+ settings : {
448+ executionOrder : 'string' ,
449+ timezone : 'string' ,
450+ callerPolicy : 'string' ,
451+ } ,
452+ meta : {
453+ templateCredsSetupCompleted : false ,
454+ } ,
455+ versionId : 'string' ,
456+ triggerCount : 1 ,
457+ } ,
458+ } ,
459+ } ,
460+ } ) ;
461+ } ) ;
462+ } ) ;
101463} ) ;
0 commit comments