Created
October 16, 2020 19:40
-
-
Save huang47/866bd98e013663eeb0c11f8926311dd3 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const module = { exports: {} }; | |
const get = (o, path) => path.split('.').reduce((a, c) => a[c] ? a[c] : {}, o || {}); | |
// User Roles | |
const USER_ROLE = { | |
MOBILE_DISTRIBUTION: 'MOBILE_DISTRIBUTION', | |
}; | |
// Status | |
const TASK_STATUS = { | |
APPROVED: 'approved', | |
CANCELED: 'canceled', | |
COMPLETED: 'completed', | |
IN_PROGRESS: 'in-progress', | |
NOT_STARTED: 'not-started', | |
PENDING_APPROVAL: 'pending-approval', | |
WAIVED: 'waived', | |
}; | |
const PROJECT_STATUS = { | |
ACTIVE: 'active', | |
ARCHIVED: 'archived', | |
SETUP: 'setup', | |
INSTALLATION: 'installation', | |
VERIFICATION: 'verification', | |
TESTING: 'testing', | |
ALLOWLISTING: 'allowlisting', | |
READY: 'ready', | |
CANCELED: 'canceled', | |
COMPLETED: 'completed', | |
IN_PROGRESS: 'in-progress', | |
}; | |
// Channel stuff | |
const CHANNEL_TYPE = { | |
PRELOAD: 'preload', | |
POSTLOAD: 'postload', | |
GPAI: 'gpai', | |
}; | |
const DISTRIBUTION_TYPE = { | |
OPEN_MARKET: 'open-market', | |
CARRIER: 'carrier', | |
}; | |
const RST_STATUS = { | |
NOT_SET: 'not-set', | |
ELIGIBLE: 'eligible', | |
INELIGIBLE: 'not-eligible', | |
}; | |
const RST_CHANNEL_SUB_TYPES = 'CHANNEL_UUID'; | |
// Device stuff | |
const DEVICE_CATEGORY = { | |
SMARTPHONE: 'smartphone', | |
TABLET: 'tablet', | |
}; | |
const DEVICE_FUNCTIONALITY = { | |
SD: 'sd', | |
HD: 'hd', | |
HD_HDR: 'hd-hdr', | |
}; | |
// Milestones | |
const MILESTONE = { | |
FIRMWARE_LOCK: 'firmware-lock', | |
LAUNCH: 'launch', | |
}; | |
// Files | |
const FILE_TYPE = { | |
SCREENSHOT: 'screenshot', | |
TEST_RESULTS: 'test-results', | |
BSP: 'bsp', | |
}; | |
// This is the API facing apk type | |
const APK_TYPE = { | |
ACTIVATION: 'activation', | |
STUB: 'stub', | |
}; | |
// This is the actual apk package type generated and stored in S3 | |
const APK_PACKAGE_TYPE = { | |
RELEASE: 'release', | |
DEBUG: 'debug', | |
}; | |
const PRODUCT_TYPE = { | |
CHANNEL: 'channel', | |
DEVICE_MODEL_GROUP: 'device_model_group', | |
}; | |
const WORKFLOW_TYPE = { | |
get DEFAULT() { | |
return this.OEM; | |
}, | |
OEM: 'OEM', | |
}; | |
const sendApprovalEmailToPEM = () => {}; | |
const sendRejectEmailToPartner = () => {}; | |
const isNetflixEmployee = () => true; | |
const canStartOnsiteTesting = () => true; | |
const EVENT_TYPE = { | |
ALLOWLISTING_APPROVED: 'ALLOWLISTING_APPROVED', | |
ALLOWLISTING_COMPLETED: 'ALLOWLISTING_COMPLETED', | |
ALLOWLISTING_REJECTED: 'ALLOWLISTING_REJECTED', | |
ALLOWLISTING_STARTED: 'ALLOWLISTING_STARTED', | |
ALLOWLISTING_UNAPPROVED: 'ALLOWLISTING_UNAPPROVED', | |
APK_DOWNLOADED: 'APK_DOWNLOADED', | |
BSP_UPLOADED: 'BSP_UPLOADED', | |
CANCELED: 'CANCELED', | |
DEVICE_SETUP_APPROVED: 'DEVICE_SETUP_APPROVED', | |
DEVICE_SETUP_COMPLETED: 'DEVICE_SETUP_COMPLETED', | |
DEVICE_SETUP_REJECTED: 'DEVICE_SETUP_REJECTED', | |
DEVICE_SETUP_STARTED: 'DEVICE_SETUP_STARTED', | |
DEVICE_SETUP_UNAPPROVED: 'DEVICE_SETUP_UNAPPROVED', | |
INSTALLATION_APPROVED: 'INSTALLATION_APPROVED', | |
INSTALLATION_COMPLETED: 'INSTALLATION_COMPLETED', | |
INSTALLATION_REJECTED: 'INSTALLATION_REJECTED', | |
INSTALLATION_STARTED: 'INSTALLATION_STARTED', | |
INSTALLATION_UNAPPROVED: 'INSTALLATION_UNAPPROVED', | |
ONSITE_TESTING_STARTED: 'ONSITE_TESTING_STARTED', | |
ONSITE_TESTING_CREATE_TRACKING_DATA: 'ONSITE_TESTING_CREATE_TRACKING_DATA', | |
ONSITE_TESTING_UPDATE_TESTING_STATUS: 'ONSITE_TESTING_UPDATE_TESTING_STATUS', | |
ONSITE_TESTING_COMPLETED: 'ONSITE_TESTING_COMPLETED', | |
ONSITE_TESTING_APPROVED: 'ONSITE_TESTING_APPROVED', | |
ONSITE_TESTING_REJECTED: 'ONSITE_TESTING_REJECTED', | |
ONSITE_TESTING_UNAPPROVED: 'ONSITE_TESTING_UNAPPROVED', | |
SCREENSHOT_UPLOADED: 'SCREENSHOT_UPLOADED', | |
SPEC_UPDATED: 'SPEC_UPDATED', | |
TEST_CASES_DOWNLOADED: 'TEST_CASES_DOWNLOADED', | |
TEST_RESULTS_UPLOADED: 'TEST_RESULTS_UPLOADED', | |
VERIFICATION_APPROVED: 'VERIFICATION_APPROVED', | |
VERIFICATION_COMPLETED: 'VERIFICATION_COMPLETED', | |
VERIFICATION_REJECTED: 'VERIFICATION_REJECTED', | |
VERIFICATION_STARTED: 'VERIFICATION_STARTED', | |
VERIFICATION_UNAPPROVED: 'VERIFICATION_UNAPPROVED', | |
}; | |
const TASK_KEY = 'testing'; | |
const { | |
updateStatus, | |
updateData, | |
markAsCompleted, | |
markAsRejected, | |
markAsUnapproved, | |
} = { | |
updateStatus: () => {}, | |
updateData: () => {}, | |
markAsCompleted: () => {}, | |
markAsRejected: () => {}, | |
markAsUnapproved: () => {}, | |
} | |
const canWaiveOnsiteTesting = () => false; | |
const isTestingApproved = (c, e) => e && e.data && e.data.status === 'completed'; | |
const TestingTask = { | |
initial: TASK_STATUS.NOT_STARTED, | |
context: {}, | |
states: { | |
[TASK_STATUS.NOT_STARTED]: { | |
entry: updateStatus(TASK_STATUS.NOT_STARTED), | |
always: { | |
target: TASK_STATUS.WAIVED, | |
cond: canWaiveOnsiteTesting, | |
}, | |
on: { | |
[EVENT_TYPE.ONSITE_TESTING_STARTED]: TASK_STATUS.IN_PROGRESS, | |
}, | |
}, | |
[TASK_STATUS.IN_PROGRESS]: { | |
entry: updateStatus(TASK_STATUS.IN_PROGRESS), | |
on: { | |
[EVENT_TYPE.ONSITE_TESTING_CREATE_TRACKING_DATA]: { | |
target: TASK_STATUS.IN_PROGRESS, | |
actions: updateData('tracking'), | |
}, | |
[EVENT_TYPE.ONSITE_TESTING_COMPLETED]: { | |
target: TASK_STATUS.PENDING_APPROVAL, | |
actions: [markAsCompleted, sendApprovalEmailToPEM], | |
}, | |
}, | |
}, | |
[TASK_STATUS.PENDING_APPROVAL]: { | |
entry: updateStatus(TASK_STATUS.PENDING_APPROVAL), | |
on: { | |
[EVENT_TYPE.ONSITE_TESTING_UPDATE_TESTING_STATUS]: { | |
target: TASK_STATUS.APPROVED, | |
cond: isTestingApproved, | |
}, | |
[EVENT_TYPE.ONSITE_TESTING_REJECTED]: { | |
target: TASK_STATUS.IN_PROGRESS, | |
actions: [markAsRejected, sendRejectEmailToPartner], | |
}, | |
}, | |
}, | |
[TASK_STATUS.APPROVED]: { | |
entry: updateStatus(TASK_STATUS.APPROVED), | |
always: { | |
target: '#project.allowlisting', | |
}, | |
on: { | |
[EVENT_TYPE.ONSITE_TESTING_UNAPPROVED]: { | |
target: TASK_STATUS.IN_PROGRESS, | |
actions: markAsUnapproved, | |
}, | |
}, | |
}, | |
[TASK_STATUS.WAIVED]: { | |
entry: updateStatus(TASK_STATUS.WAIVED), | |
always: { | |
target: '#project.allowlisting', | |
}, | |
}, | |
}, | |
}; | |
const machine = Machine(TestingTask); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment