How to use fields method in devicefarmer-stf

Best JavaScript code snippet using devicefarmer-stf

Zoom.node.ts

Source:Zoom.node.ts Github

copy

Full Screen

1import { IExecuteFunctions } from 'n8n-core';2import {3 IDataObject,4 ILoadOptionsFunctions,5 INodeExecutionData,6 INodePropertyOptions,7 INodeType,8 INodeTypeDescription,9} from 'n8n-workflow';10import { zoomApiRequest, zoomApiRequestAllItems } from './GenericFunctions';11import { meetingFields, meetingOperations } from './MeetingDescription';12// import {13// meetingRegistrantOperations,14// meetingRegistrantFields,15// } from './MeetingRegistrantDescription';16// import {17// webinarOperations,18// webinarFields,19// } from './WebinarDescription';20import moment from 'moment-timezone';21interface Settings {22 host_video?: boolean;23 participant_video?: boolean;24 panelists_video?: boolean;25 cn_meeting?: boolean;26 in_meeting?: boolean;27 join_before_host?: boolean;28 mute_upon_entry?: boolean;29 watermark?: boolean;30 waiting_room?: boolean;31 audio?: string;32 alternative_hosts?: string;33 auto_recording?: string;34 registration_type?: number;35 approval_type?: number;36 practice_session?: boolean;37}38export class Zoom implements INodeType {39 description: INodeTypeDescription = {40 displayName: 'Zoom',41 name: 'zoom',42 group: ['input'],43 version: 1,44 description: 'Consume Zoom API',45 subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',46 defaults: {47 name: 'Zoom',48 },49 icon: 'file:zoom.svg',50 inputs: ['main'],51 outputs: ['main'],52 credentials: [53 {54 // create a JWT app on Zoom Marketplace55 //https://marketplace.zoom.us/develop/create56 //get the JWT token as access token57 name: 'zoomApi',58 required: true,59 displayOptions: {60 show: {61 authentication: ['accessToken'],62 },63 },64 },65 {66 //create a account level OAuth app67 //https://marketplace.zoom.us/develop/create68 name: 'zoomOAuth2Api',69 required: true,70 displayOptions: {71 show: {72 authentication: ['oAuth2'],73 },74 },75 },76 ],77 properties: [78 {79 displayName: 'Authentication',80 name: 'authentication',81 type: 'options',82 options: [83 {84 name: 'Access Token',85 value: 'accessToken',86 },87 {88 name: 'OAuth2',89 value: 'oAuth2',90 },91 ],92 default: 'accessToken',93 },94 {95 displayName: 'Resource',96 name: 'resource',97 type: 'options',98 noDataExpression: true,99 options: [100 {101 name: 'Meeting',102 value: 'meeting',103 },104 // {105 // name: 'Meeting Registrant',106 // value: 'meetingRegistrant'107 // },108 // {109 // name: 'Webinar',110 // value: 'webinar'111 // }112 ],113 default: 'meeting',114 },115 //MEETINGS116 ...meetingOperations,117 ...meetingFields,118 // //MEETING REGISTRANTS119 // ...meetingRegistrantOperations,120 // ...meetingRegistrantFields,121 // //WEBINARS122 // ...webinarOperations,123 // ...webinarFields,124 ],125 };126 methods = {127 loadOptions: {128 // Get all the timezones to display them to user so that he can select them easily129 async getTimezones(this: ILoadOptionsFunctions): Promise<INodePropertyOptions[]> {130 const returnData: INodePropertyOptions[] = [];131 for (const timezone of moment.tz.names()) {132 const timezoneName = timezone;133 const timezoneId = timezone;134 returnData.push({135 name: timezoneName,136 value: timezoneId,137 });138 }139 return returnData;140 },141 },142 };143 async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {144 const items = this.getInputData();145 const returnData: INodeExecutionData[] = [];146 let qs: IDataObject = {};147 let responseData;148 const resource = this.getNodeParameter('resource', 0) as string;149 const operation = this.getNodeParameter('operation', 0) as string;150 for (let i = 0; i < items.length; i++) {151 try {152 qs = {};153 //https://marketplace.zoom.us/docs/api-reference/zoom-api/154 if (resource === 'meeting') {155 if (operation === 'get') {156 //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meeting157 const meetingId = this.getNodeParameter('meetingId', i) as string;158 const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;159 if (additionalFields.showPreviousOccurrences) {160 qs.show_previous_occurrences = additionalFields.showPreviousOccurrences as boolean;161 }162 if (additionalFields.occurrenceId) {163 qs.occurrence_id = additionalFields.occurrenceId as string;164 }165 responseData = await zoomApiRequest.call(this, 'GET', `/meetings/${meetingId}`, {}, qs);166 }167 if (operation === 'getAll') {168 //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetings169 const returnAll = this.getNodeParameter('returnAll', i) as boolean;170 const filters = this.getNodeParameter('filters', i) as IDataObject;171 if (filters.type) {172 qs.type = filters.type as string;173 }174 if (returnAll) {175 responseData = await zoomApiRequestAllItems.call(176 this,177 'meetings',178 'GET',179 '/users/me/meetings',180 {},181 qs,182 );183 } else {184 qs.page_size = this.getNodeParameter('limit', i) as number;185 responseData = await zoomApiRequest.call(this, 'GET', '/users/me/meetings', {}, qs);186 responseData = responseData.meetings;187 }188 }189 if (operation === 'delete') {190 //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingdelete191 const meetingId = this.getNodeParameter('meetingId', i) as string;192 const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;193 if (additionalFields.scheduleForReminder) {194 qs.schedule_for_reminder = additionalFields.scheduleForReminder as boolean;195 }196 if (additionalFields.occurrenceId) {197 qs.occurrence_id = additionalFields.occurrenceId;198 }199 responseData = await zoomApiRequest.call(200 this,201 'DELETE',202 `/meetings/${meetingId}`,203 {},204 qs,205 );206 responseData = { success: true };207 }208 if (operation === 'create') {209 //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingcreate210 const additionalFields = this.getNodeParameter('additionalFields', i) as IDataObject;211 const body: IDataObject = {};212 if (additionalFields.settings) {213 const settingValues: Settings = {};214 const settings = additionalFields.settings as IDataObject;215 if (settings.cnMeeting) {216 settingValues.cn_meeting = settings.cnMeeting as boolean;217 }218 if (settings.inMeeting) {219 settingValues.in_meeting = settings.inMeeting as boolean;220 }221 if (settings.joinBeforeHost) {222 settingValues.join_before_host = settings.joinBeforeHost as boolean;223 }224 if (settings.muteUponEntry) {225 settingValues.mute_upon_entry = settings.muteUponEntry as boolean;226 }227 if (settings.watermark) {228 settingValues.watermark = settings.watermark as boolean;229 }230 if (settings.audio) {231 settingValues.audio = settings.audio as string;232 }233 if (settings.alternativeHosts) {234 settingValues.alternative_hosts = settings.alternativeHosts as string;235 }236 if (settings.participantVideo) {237 settingValues.participant_video = settings.participantVideo as boolean;238 }239 if (settings.hostVideo) {240 settingValues.host_video = settings.hostVideo as boolean;241 }242 if (settings.autoRecording) {243 settingValues.auto_recording = settings.autoRecording as string;244 }245 if (settings.registrationType) {246 settingValues.registration_type = settings.registrationType as number;247 }248 body.settings = settingValues;249 }250 body.topic = this.getNodeParameter('topic', i) as string;251 if (additionalFields.type) {252 body.type = additionalFields.type as string;253 }254 if (additionalFields.startTime) {255 if (additionalFields.timeZone) {256 body.start_time = moment(additionalFields.startTime as string).format(257 'YYYY-MM-DDTHH:mm:ss',258 );259 } else {260 // if none timezone it's defined used n8n timezone261 body.start_time = moment262 .tz(additionalFields.startTime as string, this.getTimezone())263 .format();264 }265 }266 if (additionalFields.duration) {267 body.duration = additionalFields.duration as number;268 }269 if (additionalFields.scheduleFor) {270 body.schedule_for = additionalFields.scheduleFor as string;271 }272 if (additionalFields.timeZone) {273 body.timezone = additionalFields.timeZone as string;274 }275 if (additionalFields.password) {276 body.password = additionalFields.password as string;277 }278 if (additionalFields.agenda) {279 body.agenda = additionalFields.agenda as string;280 }281 responseData = await zoomApiRequest.call(this, 'POST', `/users/me/meetings`, body, qs);282 }283 if (operation === 'update') {284 //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingupdate285 const meetingId = this.getNodeParameter('meetingId', i) as string;286 const updateFields = this.getNodeParameter('updateFields', i) as IDataObject;287 const body: IDataObject = {};288 if (updateFields.settings) {289 const settingValues: Settings = {};290 const settings = updateFields.settings as IDataObject;291 if (settings.cnMeeting) {292 settingValues.cn_meeting = settings.cnMeeting as boolean;293 }294 if (settings.inMeeting) {295 settingValues.in_meeting = settings.inMeeting as boolean;296 }297 if (settings.joinBeforeHost) {298 settingValues.join_before_host = settings.joinBeforeHost as boolean;299 }300 if (settings.muteUponEntry) {301 settingValues.mute_upon_entry = settings.muteUponEntry as boolean;302 }303 if (settings.watermark) {304 settingValues.watermark = settings.watermark as boolean;305 }306 if (settings.audio) {307 settingValues.audio = settings.audio as string;308 }309 if (settings.alternativeHosts) {310 settingValues.alternative_hosts = settings.alternativeHosts as string;311 }312 if (settings.participantVideo) {313 settingValues.participant_video = settings.participantVideo as boolean;314 }315 if (settings.hostVideo) {316 settingValues.host_video = settings.hostVideo as boolean;317 }318 if (settings.autoRecording) {319 settingValues.auto_recording = settings.autoRecording as string;320 }321 if (settings.registrationType) {322 settingValues.registration_type = settings.registrationType as number;323 }324 body.settings = settingValues;325 }326 if (updateFields.topic) {327 body.topic = updateFields.topic as string;328 }329 if (updateFields.type) {330 body.type = updateFields.type as string;331 }332 if (updateFields.startTime) {333 body.start_time = updateFields.startTime as string;334 }335 if (updateFields.duration) {336 body.duration = updateFields.duration as number;337 }338 if (updateFields.scheduleFor) {339 body.schedule_for = updateFields.scheduleFor as string;340 }341 if (updateFields.timeZone) {342 body.timezone = updateFields.timeZone as string;343 }344 if (updateFields.password) {345 body.password = updateFields.password as string;346 }347 if (updateFields.agenda) {348 body.agenda = updateFields.agenda as string;349 }350 responseData = await zoomApiRequest.call(351 this,352 'PATCH',353 `/meetings/${meetingId}`,354 body,355 qs,356 );357 responseData = { success: true };358 }359 }360 // if (resource === 'meetingRegistrant') {361 // if (operation === 'create') {362 // //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingregistrantcreate363 // const meetingId = this.getNodeParameter('meetingId', i) as string;364 // const emailId = this.getNodeParameter('email', i) as string;365 // body.email = emailId;366 // const firstName = this.getNodeParameter('firstName', i) as string;367 // body.first_name = firstName;368 // const additionalFields = this.getNodeParameter(369 // 'additionalFields',370 // i371 // ) as IDataObject;372 // if (additionalFields.occurrenceId) {373 // qs.occurrence_ids = additionalFields.occurrenceId as string;374 // }375 // if (additionalFields.lastName) {376 // body.last_name = additionalFields.lastName as string;377 // }378 // if (additionalFields.address) {379 // body.address = additionalFields.address as string;380 // }381 // if (additionalFields.city) {382 // body.city = additionalFields.city as string;383 // }384 // if (additionalFields.state) {385 // body.state = additionalFields.state as string;386 // }387 // if (additionalFields.country) {388 // body.country = additionalFields.country as string;389 // }390 // if (additionalFields.zip) {391 // body.zip = additionalFields.zip as string;392 // }393 // if (additionalFields.phone) {394 // body.phone = additionalFields.phone as string;395 // }396 // if (additionalFields.comments) {397 // body.comments = additionalFields.comments as string;398 // }399 // if (additionalFields.org) {400 // body.org = additionalFields.org as string;401 // }402 // if (additionalFields.jobTitle) {403 // body.job_title = additionalFields.jobTitle as string;404 // }405 // if (additionalFields.purchasingTimeFrame) {406 // body.purchasing_time_frame = additionalFields.purchasingTimeFrame as string;407 // }408 // if (additionalFields.roleInPurchaseProcess) {409 // body.role_in_purchase_process = additionalFields.roleInPurchaseProcess as string;410 // }411 // responseData = await zoomApiRequest.call(412 // this,413 // 'POST',414 // `/meetings/${meetingId}/registrants`,415 // body,416 // qs417 // );418 // }419 // if (operation === 'getAll') {420 // //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingregistrants421 // const meetingId = this.getNodeParameter('meetingId', i) as string;422 // const additionalFields = this.getNodeParameter(423 // 'additionalFields',424 // i425 // ) as IDataObject;426 // if (additionalFields.occurrenceId) {427 // qs.occurrence_id = additionalFields.occurrenceId as string;428 // }429 // if (additionalFields.status) {430 // qs.status = additionalFields.status as string;431 // }432 // const returnAll = this.getNodeParameter('returnAll', i) as boolean;433 // if (returnAll) {434 // responseData = await zoomApiRequestAllItems.call(this, 'results', 'GET', `/meetings/${meetingId}/registrants`, {}, qs);435 // } else {436 // qs.page_size = this.getNodeParameter('limit', i) as number;437 // responseData = await zoomApiRequest.call(this, 'GET', `/meetings/${meetingId}/registrants`, {}, qs);438 // }439 // }440 // if (operation === 'update') {441 // //https://marketplace.zoom.us/docs/api-reference/zoom-api/meetings/meetingregistrantstatus442 // const meetingId = this.getNodeParameter('meetingId', i) as string;443 // const additionalFields = this.getNodeParameter(444 // 'additionalFields',445 // i446 // ) as IDataObject;447 // if (additionalFields.occurrenceId) {448 // qs.occurrence_id = additionalFields.occurrenceId as string;449 // }450 // if (additionalFields.action) {451 // body.action = additionalFields.action as string;452 // }453 // responseData = await zoomApiRequest.call(454 // this,455 // 'PUT',456 // `/meetings/${meetingId}/registrants/status`,457 // body,458 // qs459 // );460 // }461 // }462 // if (resource === 'webinar') {463 // if (operation === 'create') {464 // //https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinarcreate465 // const userId = this.getNodeParameter('userId', i) as string;466 // const additionalFields = this.getNodeParameter(467 // 'additionalFields',468 // i469 // ) as IDataObject;470 // const settings: Settings = {};471 // if (additionalFields.audio) {472 // settings.audio = additionalFields.audio as string;473 // }474 // if (additionalFields.alternativeHosts) {475 // settings.alternative_hosts = additionalFields.alternativeHosts as string;476 // }477 // if (additionalFields.panelistsVideo) {478 // settings.panelists_video = additionalFields.panelistsVideo as boolean;479 // }480 // if (additionalFields.hostVideo) {481 // settings.host_video = additionalFields.hostVideo as boolean;482 // }483 // if (additionalFields.practiceSession) {484 // settings.practice_session = additionalFields.practiceSession as boolean;485 // }486 // if (additionalFields.autoRecording) {487 // settings.auto_recording = additionalFields.autoRecording as string;488 // }489 // if (additionalFields.registrationType) {490 // settings.registration_type = additionalFields.registrationType as number;491 // }492 // if (additionalFields.approvalType) {493 // settings.approval_type = additionalFields.approvalType as number;494 // }495 // body = {496 // settings,497 // };498 // if (additionalFields.topic) {499 // body.topic = additionalFields.topic as string;500 // }501 // if (additionalFields.type) {502 // body.type = additionalFields.type as string;503 // }504 // if (additionalFields.startTime) {505 // body.start_time = additionalFields.startTime as string;506 // }507 // if (additionalFields.duration) {508 // body.duration = additionalFields.duration as number;509 // }510 // if (additionalFields.timeZone) {511 // body.timezone = additionalFields.timeZone as string;512 // }513 // if (additionalFields.password) {514 // body.password = additionalFields.password as string;515 // }516 // if (additionalFields.agenda) {517 // body.agenda = additionalFields.agenda as string;518 // }519 // responseData = await zoomApiRequest.call(520 // this,521 // 'POST',522 // `/users/${userId}/webinars`,523 // body,524 // qs525 // );526 // }527 // if (operation === 'get') {528 // //https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinar529 // const webinarId = this.getNodeParameter('webinarId', i) as string;530 // const additionalFields = this.getNodeParameter(531 // 'additionalFields',532 // i533 // ) as IDataObject;534 // if (additionalFields.showPreviousOccurrences) {535 // qs.show_previous_occurrences = additionalFields.showPreviousOccurrences as boolean;536 // }537 // if (additionalFields.occurrenceId) {538 // qs.occurrence_id = additionalFields.occurrenceId as string;539 // }540 // responseData = await zoomApiRequest.call(541 // this,542 // 'GET',543 // `/webinars/${webinarId}`,544 // {},545 // qs546 // );547 // }548 // if (operation === 'getAll') {549 // //https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinars550 // const userId = this.getNodeParameter('userId', i) as string;551 // const returnAll = this.getNodeParameter('returnAll', i) as boolean;552 // if (returnAll) {553 // responseData = await zoomApiRequestAllItems.call(this, 'results', 'GET', `/users/${userId}/webinars`, {}, qs);554 // } else {555 // qs.page_size = this.getNodeParameter('limit', i) as number;556 // responseData = await zoomApiRequest.call(this, 'GET', `/users/${userId}/webinars`, {}, qs);557 // }558 // }559 // if (operation === 'delete') {560 // //https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinardelete561 // const webinarId = this.getNodeParameter('webinarId', i) as string;562 // const additionalFields = this.getNodeParameter(563 // 'additionalFields',564 // i565 // ) as IDataObject;566 // if (additionalFields.occurrenceId) {567 // qs.occurrence_id = additionalFields.occurrenceId;568 // }569 // responseData = await zoomApiRequest.call(570 // this,571 // 'DELETE',572 // `/webinars/${webinarId}`,573 // {},574 // qs575 // );576 // responseData = { success: true };577 // }578 // if (operation === 'update') {579 // //https://marketplace.zoom.us/docs/api-reference/zoom-api/webinars/webinarupdate580 // const webinarId = this.getNodeParameter('webinarId', i) as string;581 // const additionalFields = this.getNodeParameter(582 // 'additionalFields',583 // i584 // ) as IDataObject;585 // if (additionalFields.occurrenceId) {586 // qs.occurrence_id = additionalFields.occurrenceId as string;587 // }588 // const settings: Settings = {};589 // if (additionalFields.audio) {590 // settings.audio = additionalFields.audio as string;591 // }592 // if (additionalFields.alternativeHosts) {593 // settings.alternative_hosts = additionalFields.alternativeHosts as string;594 // }595 // if (additionalFields.panelistsVideo) {596 // settings.panelists_video = additionalFields.panelistsVideo as boolean;597 // }598 // if (additionalFields.hostVideo) {599 // settings.host_video = additionalFields.hostVideo as boolean;600 // }601 // if (additionalFields.practiceSession) {602 // settings.practice_session = additionalFields.practiceSession as boolean;603 // }604 // if (additionalFields.autoRecording) {605 // settings.auto_recording = additionalFields.autoRecording as string;606 // }607 // if (additionalFields.registrationType) {608 // settings.registration_type = additionalFields.registrationType as number;609 // }610 // if (additionalFields.approvalType) {611 // settings.approval_type = additionalFields.approvalType as number;612 // }613 // body = {614 // settings,615 // };616 // if (additionalFields.topic) {617 // body.topic = additionalFields.topic as string;618 // }619 // if (additionalFields.type) {620 // body.type = additionalFields.type as string;621 // }622 // if (additionalFields.startTime) {623 // body.start_time = additionalFields.startTime as string;624 // }625 // if (additionalFields.duration) {626 // body.duration = additionalFields.duration as number;627 // }628 // if (additionalFields.timeZone) {629 // body.timezone = additionalFields.timeZone as string;630 // }631 // if (additionalFields.password) {632 // body.password = additionalFields.password as string;633 // }634 // if (additionalFields.agenda) {635 // body.agenda = additionalFields.agenda as string;636 // }637 // responseData = await zoomApiRequest.call(638 // this,639 // 'PATCH',640 // `webinars/${webinarId}`,641 // body,642 // qs643 // );644 // }645 // }646 const executionData = this.helpers.constructExecutionMetaData(647 this.helpers.returnJsonArray(returnData),648 { itemData: { item: i } },649 );650 returnData.push(...executionData);651 } catch (error) {652 if (this.continueOnFail()) {653 const executionErrorData = {654 json: {} as IDataObject,655 error: error.message,656 itemIndex: i,657 };658 returnData.push(executionErrorData as INodeExecutionData);659 continue;660 }661 throw error;662 }663 }664 return this.prepareOutputData(returnData);665 }...

Full Screen

Full Screen

index.js

Source:index.js Github

copy

Full Screen

1import moment from 'moment'2import _ from 'lodash'3import { default as fieldTypes, formBindType, isBindFormType } from './fieldTypes'4/*5 * 获取date数据的时间戳6 */7const getDateValue = (value, defaultValue = undefined) => {8 return value ? value.valueOf() : defaultValue9}10/*11 * 获取表单field数组12 * 示例:13 * const formFields = getFields(fields,['name','author'],{ name: { rules: []}}).values();14 * const formFields = getFields(fields).excludes(['id','desc']).values();15 * const formFields = getFields(fields).pick(['name','author','openTime']).values();16 * @param originField 原始fields17 * @param fieldKeys 需要包含的字段keys18 * @param extraFields 扩展的fields19 * @result 链式写法,返回链式对象(包含pick,excludes,enhance,values方法), 需要调用values返回最终的数据20 */21const getSearchFields = (originFields, fieldKeys) => {22 const chain = {}23 let fields = [...originFields]24 const pick = keys => {25 keys = [].concat(keys)26 fields = keys.map(key => {27 let field28 for (let i in fields) {29 const item = fields[i]30 if (key === item.key) {31 field = key32 }33 }34 if (!field) {35 // 如果field不存在,则默认类型的field36 field = {37 key,38 name: key,39 }40 }41 return field42 })43 return chain44 }45 const excludes = keys => {46 keys = [].concat(keys)47 fields = fields.filter(field => {48 for (let i in keys) {49 const item = keys[i]50 if (item !== field.key) {51 return true52 }53 }54 return false55 })56 return chain57 }58 const values = () => {59 return fields60 }61 const mixins = keys => {62 keys = [].concat(keys)63 fields = keys.map(key => {64 let field65 if (typeof key === 'string') {66 for (let i in fields) {67 const item = fields[i]68 if (item.key === key) {69 field = item70 continue71 }72 }73 if (!field) {74 field = { key }75 }76 } else {77 field = key78 }79 return field80 })81 return chain82 }83 if (fieldKeys) {84 mixins(fieldKeys)85 }86 return Object.assign(chain, {87 pick,88 excludes,89 values,90 })91}92/*93 * 获取表单field数组94 * 示例:95 * const formFields = getFields(fields,['name','author'],{ name: { rules: []}}).values();96 * const formFields = getFields(fields).excludes(['id','desc']).values();97 * const formFields = getFields(fields).pick(['name','author','openTime']).enhance({name:{ rules: [] }}).values();98 * @param originField 原始fields99 * @param fieldKeys 需要包含的字段keys100 * @param extraFields 扩展的fields101 * @result 链式写法,返回链式对象(包含pick,excludes,enhance,values方法), 需要调用values返回最终的数据102 */103const getFields = (originFields, fieldKeys, extraFields) => {104 const chain = {}105 let fields = [...originFields]106 const pick = keys => {107 keys = [].concat(keys)108 fields = keys.map(key => {109 let field110 for (let i in fields) {111 const item = fields[i]112 if (key === item.key) {113 field = key114 }115 }116 if (!field) {117 // 如果field不存在,则默认类型的field118 field = {119 key,120 name: key,121 }122 }123 return field124 })125 return chain126 }127 const excludes = keys => {128 keys = [].concat(keys)129 fields = fields.filter(field => {130 for (let i in keys) {131 const item = keys[i]132 if (item === field.key) {133 return false134 }135 }136 return true137 })138 return chain139 }140 const enhance = _extraFields => {141 if (!Array.isArray(_extraFields)) {142 _extraFields = Object.keys(_extraFields).map(key => {143 return Object.assign(_extraFields[key], {144 key,145 })146 })147 }148 _extraFields.forEach(extraField => {149 let field150 for (let i in fields) {151 const item = fields[i]152 if (item.key === extraField.key) {153 field = item154 }155 }156 if (field) {157 Object.assign(field, extraField)158 } else {159 fields.push(extraField)160 }161 })162 return chain163 }164 const values = () => {165 return fields166 }167 const toMapValues = () => {168 return fields.reduce((map, field) => {169 map[field.key] = field170 return map171 }, {})172 }173 const mixins = keys => {174 keys = [].concat(keys)175 fields = keys.map(key => {176 let field177 if (typeof key === 'string') {178 for (let i in fields) {179 const item = fields[i]180 if (item.key === key) {181 field = item182 continue183 }184 }185 if (!field) {186 field = { key }187 }188 } else {189 field = key190 }191 return field192 })193 return chain194 }195 if (fieldKeys) {196 mixins(fieldKeys)197 }198 if (extraFields) {199 enhance(extraFields)200 }201 return Object.assign(chain, {202 pick,203 excludes,204 enhance,205 values,206 toMapValues,207 })208}209/*210 * 创建antd fieldDecorator211 */212const createFieldDecorator = (field,213 item,214 getFieldDecorator,215 placeholder,216 inputProps = {},217 decoratorOpts = {},218 isText = false,219 currentForm,) => {220 const { key } = field221 let { type, rules, enums, render, formRender, meta, required, form } = field222 type =223 (Object.prototype.hasOwnProperty.call(fieldTypes, type) && type) ||224 (form && form.enums && 'enum') ||225 (enums && 'enum') ||226 'text'227 if (type === 'switch') {228 decoratorOpts = {229 valuePropName: 'checked',230 }231 }232 let inputValue233 let hasFormRender = false234 if (formRender) {235 hasFormRender = true236 inputValue = formRender(item[key], item)237 } else {238 inputValue = item[key]239 }240 const typedItem = fieldTypes[type]({241 initialValue: inputValue || null,242 meta,243 field,244 inputProps,245 placeholder,246 isText,247 currentForm,248 hasFormRender,249 })250 let { submit, input, initialValue } = typedItem251 if (React.isValidElement(typedItem)) {252 input = typedItem253 initialValue = inputValue254 }255 if (required && !rules) {256 rules = [257 {258 required: true,259 message: `请输入${field.name}`,260 },261 ]262 }263 if ((field.submit !== undefined && !field.submit) || (submit !== undefined && !submit)) {264 return input265 }266 return getFieldDecorator(key, { initialValue, rules, inputProps, ...decoratorOpts })(input)267}268/*269 * 包装antd form validateFields270 * 主要用途自动转换date类型数据,validateFields提供的错误处理大部分情况下都用不到,故提供一个包装函数,简化使用271 * 示例:272 * validate(form, fields)((values) => {273 * onSave({274 * ...values,275 * });276 * });277 * @param form, antd form对象278 * @param 返回result函数,参数为: onSuccess, onError279 */280const validate = (form, fields, formType) => {281 const { validateFields } = form282 const transformValues = values => {283 const newValues = {}284 Object.keys(values).forEach(key => {285 const item = _.find(fields, e => e.key === key)286 const value = values[key]287 const isDateTimeType = value && value instanceof moment288 let newValue289 if (isDateTimeType) {290 if (item) {291 if (typeof item.format === 'boolean' && !item.format) {292 newValue = values[key]293 } else if (item.format) {294 newValue = values[key].format(item.format)295 } else if (/^date$/.test(item.type)) {296 newValue = values[key].format('YYYY-MM-DD')297 } else if (/^datetime$/.test(item.type)) {298 newValue = values[key].format('YYYY-MM-DD hh:mm:ss')299 } else {300 newValue = getDateValue(values[key])301 }302 } else {303 newValue = getDateValue(values[key])304 }305 } else {306 newValue = values[key]307 }308 // 如果value为undefined,则不赋值到values对象上309 if (newValue !== undefined) {310 if (item !== undefined && item.submit !== undefined && !item.submit) {311 return312 } else if (313 item !== undefined &&314 formType !== undefined &&315 item[formType] !== undefined &&316 item[formType].submit !== undefined &&317 !item[formType].submit318 ) {319 return320 }321 newValues[key] = newValue322 }323 })324 return newValues325 }326 return (onSuccess, onError) => {327 validateFields((errors, values) => {328 if (errors) {329 onError && onError(errors)330 } else {331 onSuccess(transformValues(values), values)332 }333 })334 }335}336export default {337 isBindFormType,338 fieldTypes,339 formBindType,340 getFields,341 getSearchFields,342 validate,343 getDateValue,344 createFieldDecorator,...

Full Screen

Full Screen

createFieldsStore.js

Source:createFieldsStore.js Github

copy

Full Screen

1'use strict';2Object.defineProperty(exports, "__esModule", {3 value: true4});5var _defineProperty2 = require('babel-runtime/helpers/defineProperty');6var _defineProperty3 = _interopRequireDefault(_defineProperty2);7var _extends2 = require('babel-runtime/helpers/extends');8var _extends3 = _interopRequireDefault(_extends2);9var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');10var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);11var _createClass2 = require('babel-runtime/helpers/createClass');12var _createClass3 = _interopRequireDefault(_createClass2);13exports['default'] = createFieldsStore;14var _set = require('lodash/set');15var _set2 = _interopRequireDefault(_set);16var _createFormField = require('./createFormField');17var _createFormField2 = _interopRequireDefault(_createFormField);18var _utils = require('./utils');19function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }20function partOf(a, b) {21 return b.indexOf(a) === 0 && ['.', '['].indexOf(b[a.length]) !== -1;22}23function internalFlattenFields(fields) {24 return (0, _utils.flattenFields)(fields, function (_, node) {25 return (0, _createFormField.isFormField)(node);26 }, 'You must wrap field data with `createFormField`.');27}28var FieldsStore = function () {29 function FieldsStore(fields) {30 (0, _classCallCheck3['default'])(this, FieldsStore);31 _initialiseProps.call(this);32 this.fields = internalFlattenFields(fields);33 this.fieldsMeta = {};34 }35 (0, _createClass3['default'])(FieldsStore, [{36 key: 'updateFields',37 value: function updateFields(fields) {38 this.fields = internalFlattenFields(fields);39 }40 }, {41 key: 'flattenRegisteredFields',42 value: function flattenRegisteredFields(fields) {43 var validFieldsName = this.getAllFieldsName();44 return (0, _utils.flattenFields)(fields, function (path) {45 return validFieldsName.indexOf(path) >= 0;46 }, 'You cannot set a form field before rendering a field associated with the value. You can use `getFieldDecorator(id, options)` instead `v-decorator="[id, options]"` to register it before render.');47 }48 }, {49 key: 'setFields',50 value: function setFields(fields) {51 var _this = this;52 var fieldsMeta = this.fieldsMeta;53 var nowFields = (0, _extends3['default'])({}, this.fields, fields);54 var nowValues = {};55 Object.keys(fieldsMeta).forEach(function (f) {56 nowValues[f] = _this.getValueFromFields(f, nowFields);57 });58 Object.keys(nowValues).forEach(function (f) {59 var value = nowValues[f];60 var fieldMeta = _this.getFieldMeta(f);61 if (fieldMeta && fieldMeta.normalize) {62 var nowValue = fieldMeta.normalize(value, _this.getValueFromFields(f, _this.fields), nowValues);63 if (nowValue !== value) {64 nowFields[f] = (0, _extends3['default'])({}, nowFields[f], {65 value: nowValue66 });67 }68 }69 });70 this.fields = nowFields;71 }72 }, {73 key: 'resetFields',74 value: function resetFields(ns) {75 var fields = this.fields;76 var names = ns ? this.getValidFieldsFullName(ns) : this.getAllFieldsName();77 return names.reduce(function (acc, name) {78 var field = fields[name];79 if (field && 'value' in field) {80 acc[name] = {};81 }82 return acc;83 }, {});84 }85 }, {86 key: 'setFieldMeta',87 value: function setFieldMeta(name, meta) {88 this.fieldsMeta[name] = meta;89 }90 }, {91 key: 'setFieldsAsDirty',92 value: function setFieldsAsDirty() {93 var _this2 = this;94 Object.keys(this.fields).forEach(function (name) {95 var field = _this2.fields[name];96 var fieldMeta = _this2.fieldsMeta[name];97 if (field && fieldMeta && (0, _utils.hasRules)(fieldMeta.validate)) {98 _this2.fields[name] = (0, _extends3['default'])({}, field, {99 dirty: true100 });101 }102 });103 }104 }, {105 key: 'getFieldMeta',106 value: function getFieldMeta(name) {107 this.fieldsMeta[name] = this.fieldsMeta[name] || {};108 return this.fieldsMeta[name];109 }110 }, {111 key: 'getValueFromFields',112 value: function getValueFromFields(name, fields) {113 var field = fields[name];114 if (field && 'value' in field) {115 return field.value;116 }117 var fieldMeta = this.getFieldMeta(name);118 return fieldMeta && fieldMeta.initialValue;119 }120 }, {121 key: 'getValidFieldsName',122 value: function getValidFieldsName() {123 var _this3 = this;124 var fieldsMeta = this.fieldsMeta;125 return fieldsMeta ? Object.keys(fieldsMeta).filter(function (name) {126 return !_this3.getFieldMeta(name).hidden;127 }) : [];128 }129 }, {130 key: 'getAllFieldsName',131 value: function getAllFieldsName() {132 var fieldsMeta = this.fieldsMeta;133 return fieldsMeta ? Object.keys(fieldsMeta) : [];134 }135 }, {136 key: 'getValidFieldsFullName',137 value: function getValidFieldsFullName(maybePartialName) {138 var maybePartialNames = Array.isArray(maybePartialName) ? maybePartialName : [maybePartialName];139 return this.getValidFieldsName().filter(function (fullName) {140 return maybePartialNames.some(function (partialName) {141 return fullName === partialName || (0, _utils.startsWith)(fullName, partialName) && ['.', '['].indexOf(fullName[partialName.length]) >= 0;142 });143 });144 }145 }, {146 key: 'getFieldValuePropValue',147 value: function getFieldValuePropValue(fieldMeta) {148 var name = fieldMeta.name,149 getValueProps = fieldMeta.getValueProps,150 valuePropName = fieldMeta.valuePropName;151 var field = this.getField(name);152 var fieldValue = 'value' in field ? field.value : fieldMeta.initialValue;153 if (getValueProps) {154 return getValueProps(fieldValue);155 }156 return (0, _defineProperty3['default'])({}, valuePropName, fieldValue);157 }158 }, {159 key: 'getField',160 value: function getField(name) {161 return (0, _extends3['default'])({}, this.fields[name], {162 name: name163 });164 }165 }, {166 key: 'getNotCollectedFields',167 value: function getNotCollectedFields() {168 var _this4 = this;169 var fieldsName = this.getValidFieldsName();170 return fieldsName.filter(function (name) {171 return !_this4.fields[name];172 }).map(function (name) {173 return {174 name: name,175 dirty: false,176 value: _this4.getFieldMeta(name).initialValue177 };178 }).reduce(function (acc, field) {179 return (0, _set2['default'])(acc, field.name, (0, _createFormField2['default'])(field));180 }, {});181 }182 }, {183 key: 'getNestedAllFields',184 value: function getNestedAllFields() {185 var _this5 = this;186 return Object.keys(this.fields).reduce(function (acc, name) {187 return (0, _set2['default'])(acc, name, (0, _createFormField2['default'])(_this5.fields[name]));188 }, this.getNotCollectedFields());189 }190 }, {191 key: 'getFieldMember',192 value: function getFieldMember(name, member) {193 return this.getField(name)[member];194 }195 }, {196 key: 'getNestedFields',197 value: function getNestedFields(names, getter) {198 var fields = names || this.getValidFieldsName();199 return fields.reduce(function (acc, f) {200 return (0, _set2['default'])(acc, f, getter(f));201 }, {});202 }203 }, {204 key: 'getNestedField',205 value: function getNestedField(name, getter) {206 var fullNames = this.getValidFieldsFullName(name);207 if (fullNames.length === 0 || // Not registered208 fullNames.length === 1 && fullNames[0] === name // Name already is full name.209 ) {210 return getter(name);211 }212 var isArrayValue = fullNames[0][name.length] === '[';213 var suffixNameStartIndex = isArrayValue ? name.length : name.length + 1;214 return fullNames.reduce(function (acc, fullName) {215 return (0, _set2['default'])(acc, fullName.slice(suffixNameStartIndex), getter(fullName));216 }, isArrayValue ? [] : {});217 }218 }, {219 key: 'isValidNestedFieldName',220 // @private221 // BG: `a` and `a.b` cannot be use in the same form222 value: function isValidNestedFieldName(name) {223 var names = this.getAllFieldsName();224 return names.every(function (n) {225 return !partOf(n, name) && !partOf(name, n);226 });227 }228 }, {229 key: 'clearField',230 value: function clearField(name) {231 delete this.fields[name];232 delete this.fieldsMeta[name];233 }234 }]);235 return FieldsStore;236}();237var _initialiseProps = function _initialiseProps() {238 var _this6 = this;239 this.setFieldsInitialValue = function (initialValues) {240 var flattenedInitialValues = _this6.flattenRegisteredFields(initialValues);241 var fieldsMeta = _this6.fieldsMeta;242 Object.keys(flattenedInitialValues).forEach(function (name) {243 if (fieldsMeta[name]) {244 _this6.setFieldMeta(name, (0, _extends3['default'])({}, _this6.getFieldMeta(name), {245 initialValue: flattenedInitialValues[name]246 }));247 }248 });249 };250 this.getAllValues = function () {251 var fieldsMeta = _this6.fieldsMeta,252 fields = _this6.fields;253 return Object.keys(fieldsMeta).reduce(function (acc, name) {254 return (0, _set2['default'])(acc, name, _this6.getValueFromFields(name, fields));255 }, {});256 };257 this.getFieldsValue = function (names) {258 return _this6.getNestedFields(names, _this6.getFieldValue);259 };260 this.getFieldValue = function (name) {261 var fields = _this6.fields;262 return _this6.getNestedField(name, function (fullName) {263 return _this6.getValueFromFields(fullName, fields);264 });265 };266 this.getFieldsError = function (names) {267 return _this6.getNestedFields(names, _this6.getFieldError);268 };269 this.getFieldError = function (name) {270 return _this6.getNestedField(name, function (fullName) {271 return (0, _utils.getErrorStrs)(_this6.getFieldMember(fullName, 'errors'));272 });273 };274 this.isFieldValidating = function (name) {275 return _this6.getFieldMember(name, 'validating');276 };277 this.isFieldsValidating = function (ns) {278 var names = ns || _this6.getValidFieldsName();279 return names.some(function (n) {280 return _this6.isFieldValidating(n);281 });282 };283 this.isFieldTouched = function (name) {284 return _this6.getFieldMember(name, 'touched');285 };286 this.isFieldsTouched = function (ns) {287 var names = ns || _this6.getValidFieldsName();288 return names.some(function (n) {289 return _this6.isFieldTouched(n);290 });291 };292};293function createFieldsStore(fields) {294 return new FieldsStore(fields);...

Full Screen

Full Screen

field_registry.js

Source:field_registry.js Github

copy

Full Screen

1odoo.define('web.field_registry', function (require) {2"use strict";3var Registry = require('web.Registry');4return new Registry();5});6odoo.define('web._field_registry', function(require) {7"use strict";8var AbstractField = require('web.AbstractField');9var basic_fields = require('web.basic_fields');10var relational_fields = require('web.relational_fields');11var registry = require('web.field_registry');12var special_fields = require('web.special_fields');13// Basic fields14registry15 .add('abstract', AbstractField)16 .add('input', basic_fields.InputField)17 .add('integer', basic_fields.FieldInteger)18 .add('boolean', basic_fields.FieldBoolean)19 .add('date', basic_fields.FieldDate)20 .add('datetime', basic_fields.FieldDateTime)21 .add('domain', basic_fields.FieldDomain)22 .add('text', basic_fields.FieldText)23 .add('html', basic_fields.FieldText)24 .add('float', basic_fields.FieldFloat)25 .add('char', basic_fields.FieldChar)26 .add('link_button', basic_fields.LinkButton)27 .add('handle', basic_fields.HandleWidget)28 .add('email', basic_fields.FieldEmail)29 .add('phone', basic_fields.FieldPhone)30 .add('url', basic_fields.UrlWidget)31 .add('image', basic_fields.FieldBinaryImage)32 .add('binary', basic_fields.FieldBinaryFile)33 .add('monetary', basic_fields.FieldMonetary)34 .add('priority', basic_fields.PriorityWidget)35 .add('attachment_image', basic_fields.AttachmentImage)36 .add('image_selection', basic_fields.ImageSelection)37 .add('label_selection', basic_fields.LabelSelection)38 .add('state_selection', basic_fields.StateSelectionWidget)39 .add('kanban_state_selection', basic_fields.StateSelectionWidget)40 .add('boolean_favorite', basic_fields.FavoriteWidget)41 .add('boolean_button', basic_fields.FieldBooleanButton)42 .add('boolean_toggle', basic_fields.BooleanToggle)43 .add('statinfo', basic_fields.StatInfo)44 .add('percentpie', basic_fields.FieldPercentPie)45 .add('float_time', basic_fields.FieldFloatTime)46 .add('progressbar', basic_fields.FieldProgressBar)47 .add('toggle_button', basic_fields.FieldToggleBoolean)48 .add('dashboard_graph', basic_fields.JournalDashboardGraph)49 .add('ace', basic_fields.AceEditor);50// Relational fields51registry52 .add('selection', relational_fields.FieldSelection)53 .add('radio', relational_fields.FieldRadio)54 .add('many2one', relational_fields.FieldMany2One)55 .add('list.many2one', relational_fields.ListFieldMany2One)56 .add('kanban.many2one', relational_fields.KanbanFieldMany2One)57 .add('many2many', relational_fields.FieldMany2Many)58 .add('many2many_binary', relational_fields.FieldMany2ManyBinaryMultiFiles)59 .add('many2many_tags', relational_fields.FieldMany2ManyTags)60 .add('form.many2many_tags', relational_fields.FormFieldMany2ManyTags)61 .add('kanban.many2many_tags', relational_fields.KanbanFieldMany2ManyTags)62 .add('many2many_checkboxes', relational_fields.FieldMany2ManyCheckBoxes)63 .add('one2many', relational_fields.FieldOne2Many)64 .add('statusbar', relational_fields.FieldStatus)65 .add('reference', relational_fields.FieldReference)66 .add('one2many_list', relational_fields.FieldOne2Many);67// Special fields68registry69 .add('timezone_mismatch', special_fields.FieldTimezoneMismatch);...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var client = require('devicefarmer-stf-client');2var fields = client.fields;3fields.getFields(function (err, fields) {4 if (err) {5 console.log(err);6 }7 console.log(fields);8});

Full Screen

Using AI Code Generation

copy

Full Screen

1var client = require('devicefarmer-stf-client');2var fields = client.fields;3console.log(fields);4var client = require('devicefarmer-stf-client');5var fields = client.fields;6console.log(fields);7var client = require('devicefarmer-stf-client');8var fields = client.fields;9console.log(fields);10var client = require('devicefarmer-stf-client');11var fields = client.fields;12console.log(fields);13var client = require('devicefarmer-stf-client');14var fields = client.fields;15console.log(fields);16var client = require('devicefarmer-stf-client');17var fields = client.fields;18console.log(fields);19var client = require('devicefarmer-stf-client');20var fields = client.fields;21console.log(fields);22var client = require('devicefarmer-stf-client');23var fields = client.fields;24console.log(fields);25var client = require('devicefarmer-stf-client');26var fields = client.fields;27console.log(fields);

Full Screen

Using AI Code Generation

copy

Full Screen

1var client = require('devicefarmer-stf-client');2device.fields('serial').then(function (fields) {3console.log(fields);4});5var client = require('devicefarmer-stf-client');6device.fields('serial', 'model').then(function (fields) {7console.log(fields);8});9var client = require('devicefarmer-stf-client');10device.fields('serial', 'model').then(function (fields) {11console.log(fields);12});13var client = require('devicefarmer-stf-client');14device.fields('serial', 'model').then(function (fields) {15console.log(fields);16});17var client = require('devicefarmer-stf-client');18device.fields('serial', 'model').then(function (fields) {19console.log(fields);20});21var client = require('devicefarmer-stf-client');22device.fields('serial', 'model').then(function (fields) {23console.log(fields);24});25var client = require('devicefarmer-stf-client');26device.fields('serial', 'model').then(function (fields) {27console.log(fields);28});29var client = require('devicefarmer-stf-client');30device.fields('serial', 'model').then(function (fields) {31console.log(fields);32});

Full Screen

Using AI Code Generation

copy

Full Screen

1var devicefarmer = require('devicefarmer-stf-client');2var fields = devicefarmer.fields;3var device = stf.getDevice('1234567890');4device.reserve(function(err) {5 if (err) throw err;6 console.log('Reserved device');7 device.use(fields.DISPLAY, function(err) {8 if (err) throw err;9 console.log('Used device');10 device.release(function(err) {11 if (err) throw err;12 console.log('Released device');13 });14 });15});16var devicefarmer = require('devicefarmer-stf-client');17var fields = devicefarmer.fields;18var device = stf.getDevice('1234567890');19device.reserve(function(err) {20 if (err) throw err;21 console.log('Reserved device');22 device.use(fields.DISPLAY, function(err) {23 if (err) throw err;24 console.log('Used device');25 device.release(function(err) {26 if (err) throw err;27 console.log('Released device');28 });29 });30});

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var fields = stf.fields;3var devices = stf.devices;4var fields = stf.fields;5var devices = stf.devices;6fields.all(function(err, data) {7 if (err) {8 console.log(err);9 } else {10 console.log(data);11 }12});13devices.all(function(err, data) {14 if (err) {15 console.log(err);16 } else {17 console.log(data);18 }19});20devices.byField('platform', 'Android', function(err, data) {21 if (err) {22 console.log(err);23 } else {24 console.log(data);25 }26});27devices.byField('platform', 'Android', function(err, data) {28 if (err) {29 console.log(err);30 } else {31 console.log(data);32 }33});34devices.byField('platform', 'Android', function(err, data) {35 if (err) {36 console.log(err);37 } else {38 console.log(data);39 }40});41devices.byField('platform', 'Android', function(err, data) {42 if (err) {43 console.log(err);44 } else {45 console.log(data);46 }47});48devices.byField('platform', 'Android', function(err, data) {49 if (err) {50 console.log(err);51 } else {52 console.log(data);53 }54});55devices.byField('platform', 'Android', function(err, data) {56 if (err) {57 console.log(err);58 } else {59 console.log(data);60 }61});62devices.byField('platform', 'Android', function(err, data) {63 if (err) {64 console.log(err);65 } else {66 console.log(data);67 }68});69devices.byField('platform', 'Android', function(err, data) {70 if (err) {71 console.log(err);72 } else {73 console.log(data);74 }75});

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf');2var fields = stf.fields;3var options = {4};5stf.getDevices(options, function (err, devices) {6 if (err) {7 console.log(err);8 } else {9 console.log(devices);10 }11});12stf.getDevices(options, callback);13var stf = require('devicefarmer-stf');14var fields = stf.fields;15var options = {

Full Screen

Using AI Code Generation

copy

Full Screen

1var stf = require('devicefarmer-stf-client');2var fields = device.fields();3fields.then(function(data) {4 console.log(data);5});6var stf = require('devicefarmer-stf-client');7var fields = device.fields();8fields.then(function(data) {9 console.log(data);10});11var stf = require('devicefarmer-stf-client');12var fields = device.fields();13fields.then(function(data) {14 console.log(data);15});16var stf = require('devicefarmer-stf-client');17var fields = device.fields();18fields.then(function(data) {19 console.log(data);20});21var stf = require('devicefarmer-stf-client');22var fields = device.fields();23fields.then(function(data) {24 console.log(data);25});26var stf = require('devicefarmer-stf-client');27var fields = device.fields();28fields.then(function(data) {29 console.log(data);30});

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run devicefarmer-stf automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful