@opentrons/shared-data 0.0.1-alpha.20 → 0.1.0-alpha.0

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.
Files changed (154) hide show
  1. package/Makefile +1 -1
  2. package/lib/opentrons-shared-data.js +1 -1
  3. package/lib/opentrons-shared-data.js.map +1 -1
  4. package/package.json +1 -1
  5. package/js/__tests__/__snapshots__/pipettes.test.ts.snap +0 -5969
  6. package/js/__tests__/deckSchemas.test.ts +0 -87
  7. package/js/__tests__/errors.test.js +0 -21
  8. package/js/__tests__/getAreSlotsAdjacent.test.ts +0 -128
  9. package/js/__tests__/getWellNamePerMultiTip.test.ts +0 -162
  10. package/js/__tests__/labwareDefQuirks.test.ts +0 -37
  11. package/js/__tests__/labwareDefSchemaV1.test.ts +0 -82
  12. package/js/__tests__/labwareDefSchemaV2.test.ts +0 -298
  13. package/js/__tests__/moduleAccessors.test.ts +0 -50
  14. package/js/__tests__/moduleSpecsSchema.test.ts +0 -77
  15. package/js/__tests__/pipetteSchemaV2.test.ts +0 -107
  16. package/js/__tests__/pipetteSpecSchemas.test.ts +0 -48
  17. package/js/__tests__/pipettes.test.ts +0 -58
  18. package/js/__tests__/protocolSchemaV4.test.ts +0 -137
  19. package/js/__tests__/protocolSchemaV5.test.ts +0 -137
  20. package/js/__tests__/protocolSchemaV6.test.ts +0 -132
  21. package/js/__tests__/protocolSchemaV7.test.ts +0 -64
  22. package/js/__tests__/protocolValidation.test.ts +0 -83
  23. package/js/__tests__/sortWells.test.ts +0 -40
  24. package/js/__tests__/splitWellsOnColumn.test.ts +0 -21
  25. package/js/__tests__/validateErrors.test.js +0 -34
  26. package/js/constants.ts +0 -338
  27. package/js/cypressUtils.ts +0 -35
  28. package/js/errors.ts +0 -33
  29. package/js/fixtures.ts +0 -161
  30. package/js/getLabware.ts +0 -154
  31. package/js/gripper.ts +0 -29
  32. package/js/helpers/__tests__/getAdapterName.test.ts +0 -31
  33. package/js/helpers/__tests__/getDeckDefFromLoadedLabware.test.ts +0 -12
  34. package/js/helpers/__tests__/getVectorDifference.test.ts +0 -25
  35. package/js/helpers/__tests__/getVectorSum.test.ts +0 -21
  36. package/js/helpers/__tests__/labwareInference.test.ts +0 -84
  37. package/js/helpers/__tests__/orderWells.test.ts +0 -87
  38. package/js/helpers/__tests__/parseProtocolData.test.ts +0 -165
  39. package/js/helpers/__tests__/volume.test.ts +0 -108
  40. package/js/helpers/__tests__/wellSets.test.ts +0 -352
  41. package/js/helpers/get96Channel384WellPlateWells.ts +0 -44
  42. package/js/helpers/getAddressableAreasInProtocol.ts +0 -59
  43. package/js/helpers/getLoadedLabwareDefinitionsByUri.ts +0 -30
  44. package/js/helpers/getModuleVizDims.ts +0 -118
  45. package/js/helpers/getOccludedSlotCountForModule.ts +0 -13
  46. package/js/helpers/getVectorDifference.ts +0 -12
  47. package/js/helpers/getVectorSum.ts +0 -12
  48. package/js/helpers/getWellNamePerMultiTip.ts +0 -86
  49. package/js/helpers/getWellTotalVolume.ts +0 -16
  50. package/js/helpers/index.ts +0 -347
  51. package/js/helpers/labwareInference.ts +0 -92
  52. package/js/helpers/orderWells.ts +0 -69
  53. package/js/helpers/parseProtocolData.ts +0 -141
  54. package/js/helpers/volume.ts +0 -35
  55. package/js/helpers/wellIsRect.ts +0 -6
  56. package/js/helpers/wellSets.ts +0 -155
  57. package/js/index.ts +0 -14
  58. package/js/labwareTools/__tests__/__snapshots__/createIrregularLabware.test.ts.snap +0 -3
  59. package/js/labwareTools/__tests__/__snapshots__/createLabware.test.ts.snap +0 -3
  60. package/js/labwareTools/__tests__/createDefaultDisplayName.test.ts +0 -111
  61. package/js/labwareTools/__tests__/createIrregularLabware.test.ts +0 -226
  62. package/js/labwareTools/__tests__/createLabware.test.ts +0 -147
  63. package/js/labwareTools/index.ts +0 -452
  64. package/js/modules.ts +0 -97
  65. package/js/pipettes.ts +0 -89
  66. package/js/protocols.ts +0 -290
  67. package/js/schema.ts +0 -80
  68. package/js/scripts/generateDeckLayersFromSVG.js +0 -46
  69. package/js/titleCase.ts +0 -30
  70. package/js/types.ts +0 -600
  71. package/python/.coveragerc +0 -4
  72. package/python/.flake8 +0 -32
  73. package/python/Config.in +0 -10
  74. package/python/Makefile +0 -134
  75. package/python/Pipfile +0 -28
  76. package/python/Pipfile.lock +0 -645
  77. package/python/buildroot.mk +0 -30
  78. package/python/mypy.ini +0 -41
  79. package/python/opentrons_shared_data/__init__.py +0 -17
  80. package/python/opentrons_shared_data/_version.py +0 -20
  81. package/python/opentrons_shared_data/command/__init__.py +0 -52
  82. package/python/opentrons_shared_data/deck/__init__.py +0 -96
  83. package/python/opentrons_shared_data/deck/dev_types.py +0 -180
  84. package/python/opentrons_shared_data/errors/__init__.py +0 -30
  85. package/python/opentrons_shared_data/errors/categories.py +0 -60
  86. package/python/opentrons_shared_data/errors/codes.py +0 -108
  87. package/python/opentrons_shared_data/errors/exceptions.py +0 -915
  88. package/python/opentrons_shared_data/gripper/__init__.py +0 -63
  89. package/python/opentrons_shared_data/gripper/constants.py +0 -6
  90. package/python/opentrons_shared_data/gripper/gripper_definition.py +0 -101
  91. package/python/opentrons_shared_data/labware/__init__.py +0 -22
  92. package/python/opentrons_shared_data/labware/constants.py +0 -7
  93. package/python/opentrons_shared_data/labware/dev_types.py +0 -140
  94. package/python/opentrons_shared_data/labware/labware_definition.py +0 -328
  95. package/python/opentrons_shared_data/load.py +0 -57
  96. package/python/opentrons_shared_data/module/__init__.py +0 -74
  97. package/python/opentrons_shared_data/module/dev_types.py +0 -141
  98. package/python/opentrons_shared_data/pipette/__init__.py +0 -107
  99. package/python/opentrons_shared_data/pipette/dev_types.py +0 -177
  100. package/python/opentrons_shared_data/pipette/file_operation_helpers.py +0 -37
  101. package/python/opentrons_shared_data/pipette/load_data.py +0 -261
  102. package/python/opentrons_shared_data/pipette/model_constants.py +0 -123
  103. package/python/opentrons_shared_data/pipette/mutable_configurations.py +0 -431
  104. package/python/opentrons_shared_data/pipette/pipette_definition.py +0 -503
  105. package/python/opentrons_shared_data/pipette/pipette_load_name_conversions.py +0 -240
  106. package/python/opentrons_shared_data/pipette/scripts/__init__.py +0 -0
  107. package/python/opentrons_shared_data/pipette/scripts/build_json_script.py +0 -469
  108. package/python/opentrons_shared_data/pipette/scripts/update_configuration_files.py +0 -450
  109. package/python/opentrons_shared_data/pipette/types.py +0 -193
  110. package/python/opentrons_shared_data/protocol/__init__.py +0 -13
  111. package/python/opentrons_shared_data/protocol/constants.py +0 -98
  112. package/python/opentrons_shared_data/protocol/dev_types.py +0 -436
  113. package/python/opentrons_shared_data/protocol/models/__init__.py +0 -48
  114. package/python/opentrons_shared_data/protocol/models/protocol_schema_v6.py +0 -145
  115. package/python/opentrons_shared_data/protocol/models/protocol_schema_v7.py +0 -95
  116. package/python/opentrons_shared_data/protocol/models/protocol_schema_v8.py +0 -110
  117. package/python/opentrons_shared_data/protocol/models/shared_models.py +0 -111
  118. package/python/opentrons_shared_data/py.typed +0 -0
  119. package/python/opentrons_shared_data/robot/__init__.py +0 -33
  120. package/python/opentrons_shared_data/robot/dev_types.py +0 -37
  121. package/python/pytest.ini +0 -2
  122. package/python/setup.cfg +0 -5
  123. package/python/setup.py +0 -179
  124. package/python/tests/__init__.py +0 -1
  125. package/python/tests/conftest.py +0 -0
  126. package/python/tests/deck/__init__.py +0 -0
  127. package/python/tests/deck/test_list_names.py +0 -12
  128. package/python/tests/deck/test_position.py +0 -113
  129. package/python/tests/deck/test_typechecks.py +0 -28
  130. package/python/tests/errors/__init__.py +0 -1
  131. package/python/tests/errors/test_error_completeness.py +0 -19
  132. package/python/tests/errors/test_exceptions.py +0 -74
  133. package/python/tests/gripper/__init__.py +0 -0
  134. package/python/tests/gripper/test_definition.py +0 -30
  135. package/python/tests/gripper/test_load.py +0 -16
  136. package/python/tests/labware/__init__.py +0 -13
  137. package/python/tests/labware/test_typechecks.py +0 -21
  138. package/python/tests/module/__init__.py +0 -20
  139. package/python/tests/module/test_load.py +0 -49
  140. package/python/tests/module/test_typechecks.py +0 -34
  141. package/python/tests/pipette/__init__.py +0 -0
  142. package/python/tests/pipette/test_load_data.py +0 -103
  143. package/python/tests/pipette/test_mutable_configurations.py +0 -266
  144. package/python/tests/pipette/test_pipette_definition.py +0 -183
  145. package/python/tests/pipette/test_pipette_load_name_conversions.py +0 -222
  146. package/python/tests/pipette/test_typechecks.py +0 -50
  147. package/python/tests/pipette/test_validate_schema.py +0 -37
  148. package/python/tests/protocol/__init__.py +0 -15
  149. package/python/tests/protocol/test_protocol_schema_v6.py +0 -107
  150. package/python/tests/protocol/test_protocol_schema_v7.py +0 -34
  151. package/python/tests/protocol/test_protocol_schema_v8.py +0 -20
  152. package/python/tests/protocol/test_typechecks.py +0 -36
  153. package/python/tests/robot/__init__.py +0 -0
  154. package/python/tests/robot/test_typechecks.py +0 -20
package/js/pipettes.ts DELETED
@@ -1,89 +0,0 @@
1
- import pipetteNameSpecs from '../pipette/definitions/1/pipetteNameSpecs.json'
2
- import pipetteModelSpecs from '../pipette/definitions/1/pipetteModelSpecs.json'
3
- import { OT3_PIPETTES } from './constants'
4
-
5
- import type { PipetteNameSpecs, PipetteModelSpecs } from './types'
6
-
7
- type SortableProps = 'maxVolume' | 'channels'
8
-
9
- // TODO(mc, 2021-04-30): use these types, pulled directly from the JSON,
10
- // to simplify return types in this module and possibly remove some `null`s
11
- export type PipetteName = keyof typeof pipetteNameSpecs
12
- export type PipetteModel = keyof typeof pipetteModelSpecs.config
13
-
14
- // models sorted by channels and then volume by default
15
- const ALL_PIPETTE_NAMES: PipetteName[] = (Object.keys(
16
- pipetteNameSpecs
17
- ) as PipetteName[]).sort(comparePipettes(['channels', 'maxVolume']))
18
-
19
- // use a name like 'p10_single' to get specs true for all models under that name
20
- export function getPipetteNameSpecs(
21
- name: PipetteName
22
- ): PipetteNameSpecs | null {
23
- const config = pipetteNameSpecs[name] as
24
- | Omit<PipetteNameSpecs, 'name'>
25
- | undefined
26
- return config != null ? { ...config, name } : null
27
- }
28
-
29
- // specify a model, eg 'p10_single_v1.3' to get
30
- // both the name specs + model-specific specs
31
- // NOTE: this should NEVER be used in PD, which is model-agnostic
32
- export function getPipetteModelSpecs(
33
- model: PipetteModel
34
- ): PipetteModelSpecs | null | undefined {
35
- const modelSpecificFields = pipetteModelSpecs.config[model]
36
- const modelFields =
37
- modelSpecificFields &&
38
- getPipetteNameSpecs(modelSpecificFields.name as PipetteName)
39
- return modelFields && { ...modelFields, ...modelSpecificFields, model }
40
- }
41
-
42
- export function getAllPipetteNames(...sortBy: SortableProps[]): PipetteName[] {
43
- const models = [...ALL_PIPETTE_NAMES]
44
- if (sortBy.length) models.sort(comparePipettes(sortBy))
45
- return models
46
- }
47
-
48
- function comparePipettes(sortBy: SortableProps[]) {
49
- return (modelA: PipetteName, modelB: PipetteName) => {
50
- // any cast is because we know these pipettes exist
51
- const a = getPipetteNameSpecs(modelA) as PipetteNameSpecs
52
- const b = getPipetteNameSpecs(modelB) as PipetteNameSpecs
53
- let i
54
-
55
- for (i = 0; i < sortBy.length; i++) {
56
- const sortKey = sortBy[i]
57
- if (a[sortKey] < b[sortKey]) return -1
58
- if (a[sortKey] > b[sortKey]) return 1
59
- }
60
-
61
- return 0
62
- }
63
- }
64
-
65
- export function shouldLevel(specs: PipetteNameSpecs): boolean {
66
- return specs.displayCategory === 'GEN2' && specs.channels === 8
67
- }
68
-
69
- export function isFlexPipette(pipetteName: PipetteName): boolean {
70
- return (
71
- OT3_PIPETTES.includes(pipetteName) ||
72
- getPipetteNameSpecs(pipetteName)?.displayCategory === 'FLEX'
73
- )
74
- }
75
-
76
- export const getIncompatiblePipetteNames = (
77
- currentPipette: PipetteName
78
- ): string[] => {
79
- if (isFlexPipette(currentPipette)) {
80
- return getAllPipetteNames().filter(pipette => !isFlexPipette(pipette))
81
- } else if (
82
- getPipetteNameSpecs(currentPipette)?.displayCategory === 'GEN1' ||
83
- getPipetteNameSpecs(currentPipette)?.displayCategory === 'GEN2'
84
- ) {
85
- return getAllPipetteNames().filter(pipette => isFlexPipette(pipette))
86
- } else {
87
- return []
88
- }
89
- }
package/js/protocols.ts DELETED
@@ -1,290 +0,0 @@
1
- // Helper functions for validating protocols. Used only in tests right now but
2
- // intended for use as the thing that turns something from a json document into
3
- // a protocol inside the js ecosystem.
4
-
5
- import Ajv from 'ajv'
6
-
7
- import commandSchema8 from '../command/schemas/8.json'
8
- import commandSchema7 from '../command/schemas/7.json'
9
- import commandAnnotationSchema1 from '../commandAnnotation/schemas/1.json'
10
- import liquidSchema1 from '../liquid/schemas/1.json'
11
- import labwareSchema2 from '../labware/schemas/2.json'
12
-
13
- import protocolSchema8 from '../protocol/schemas/8.json'
14
- import protocolSchema7 from '../protocol/schemas/7.json'
15
- import protocolSchema6 from '../protocol/schemas/6.json'
16
- import protocolSchema5 from '../protocol/schemas/5.json'
17
- import protocolSchema4 from '../protocol/schemas/4.json'
18
- import protocolSchema3 from '../protocol/schemas/3.json'
19
- import protocolSchema1 from '../protocol/schemas/1.json'
20
-
21
- import type * as ProtocolSchemas from '../protocol'
22
- import type { CreateCommand } from '../command/types'
23
- import type { CommandAnnotation } from '../commandAnnotation/types'
24
-
25
- export type { ProtocolSchemas }
26
-
27
- const validateCommands8 = (
28
- toValidate: ProtocolSchemas.ProtocolStructureV8
29
- ): Promise<CreateCommand[]> =>
30
- new Promise((resolve, reject) => {
31
- const requestedSchema = toValidate.commandSchemaId
32
- switch (requestedSchema) {
33
- case 'opentronsCommandSchemaV8':
34
- resolve(commandSchema8)
35
- break
36
- default:
37
- // eslint-disable-next-line prefer-promise-reject-errors
38
- reject([
39
- {
40
- keyword: 'Invalid command schema requested',
41
- dataPath: requestedSchema,
42
- schemaPath: '#/properties/commandSchemaId',
43
- params: { allowedValues: ['opentronsCommandSchemaV8'] },
44
- },
45
- ])
46
- break
47
- }
48
- }).then(
49
- schema =>
50
- new Promise((resolve, reject) => {
51
- const generatedSchema = { type: 'array', items: schema }
52
- const commandAjv = new Ajv({ allErrors: true, jsonPointers: true })
53
- const validateCommands = commandAjv.compile(generatedSchema)
54
- const ok = validateCommands(toValidate.commands)
55
- if (!ok) {
56
- // eslint-disable-next-line prefer-promise-reject-errors
57
- reject(validateCommands.errors)
58
- }
59
- resolve(toValidate.commands)
60
- })
61
- )
62
-
63
- const validateCommandAnnotations8 = (
64
- toValidate: ProtocolSchemas.ProtocolStructureV8
65
- ): Promise<CommandAnnotation[]> =>
66
- new Promise((resolve, reject) => {
67
- const requestedSchema = toValidate.commandAnnotationSchemaId
68
- switch (requestedSchema) {
69
- case 'opentronsCommandAnnotationSchemaV1':
70
- resolve(commandAnnotationSchema1)
71
- break
72
- default:
73
- // eslint-disable-next-line prefer-promise-reject-errors
74
- reject([
75
- {
76
- keyword: 'Invalid command annotation schema requested',
77
- dataPath: requestedSchema,
78
- schemaPath: '#/properties/commandAnnotationSchemaId',
79
- params: { allowedValues: ['opentronsCommandAnnotationSchemaV1'] },
80
- },
81
- ])
82
- }
83
- }).then(
84
- (schema: any) =>
85
- new Promise((resolve, reject) => {
86
- const generatedSchema = {
87
- type: 'array',
88
- items: { $ref: 'opentronsCommandAnnotationSchemaV1' },
89
- }
90
- const annotationAjv = new Ajv({ allErrors: true, jsonPointers: true })
91
- annotationAjv.addSchema(schema)
92
- const validateAnnotations = annotationAjv.compile(generatedSchema)
93
- const ok = validateAnnotations(toValidate.commandAnnotations)
94
- if (!ok) {
95
- // eslint-disable-next-line prefer-promise-reject-errors
96
- reject(validateAnnotations.errors)
97
- }
98
- resolve(toValidate.commandAnnotations)
99
- })
100
- )
101
-
102
- const validateLiquids8 = (
103
- toValidate: ProtocolSchemas.ProtocolStructureV8
104
- ): Promise<ProtocolSchemas.ProtocolFileV8['liquids']> =>
105
- new Promise((resolve, reject) => {
106
- const requestedSchema = toValidate.liquidSchemaId
107
- switch (requestedSchema) {
108
- case 'opentronsLiquidSchemaV1':
109
- resolve(liquidSchema1)
110
- break
111
- default:
112
- // eslint-disable-next-line prefer-promise-reject-errors
113
- reject([
114
- {
115
- keyword: 'Invalid liquid schema requested',
116
- dataPath: requestedSchema,
117
- schemaPath: '#/properties/liquidSchemaId',
118
- params: { allowedValues: ['opentronsLiquidSchemaV1'] },
119
- },
120
- ])
121
- }
122
- }).then(
123
- schema =>
124
- new Promise((resolve, reject) => {
125
- const generatedSchema = {
126
- type: 'object',
127
- patternProperties: { '.+': schema },
128
- }
129
- const liquidAjv = new Ajv({ allErrors: true, jsonPointers: true })
130
- const validateLiquids = liquidAjv.compile(generatedSchema)
131
- const ok = validateLiquids(toValidate.liquids)
132
- if (!ok) {
133
- // eslint-disable-next-line prefer-promise-reject-errors
134
- reject(validateLiquids.errors)
135
- }
136
- resolve(toValidate.liquids)
137
- })
138
- )
139
-
140
- const validateLabware8 = (
141
- toValidate: ProtocolSchemas.ProtocolStructureV8
142
- ): Promise<ProtocolSchemas.ProtocolFileV8['labwareDefinitions']> =>
143
- new Promise((resolve, reject) => {
144
- const requestedSchema = toValidate.labwareDefinitionSchemaId
145
- switch (requestedSchema) {
146
- case 'opentronsLabwareSchemaV2':
147
- resolve(labwareSchema2)
148
- break
149
- default:
150
- // eslint-disable-next-line prefer-promise-reject-errors
151
- reject([
152
- {
153
- keyword: 'Invalid labware schema requested',
154
- dataPath: requestedSchema,
155
- schemaPath: '#/properties/labwareSchemaId',
156
- params: { allowedValues: ['opentronsLabwareSchemaV2'] },
157
- },
158
- ])
159
- }
160
- }).then(
161
- schema =>
162
- new Promise((resolve, reject) => {
163
- const generatedSchema = {
164
- type: 'object',
165
- patternProperties: { '.+': schema },
166
- }
167
- const labwareAjv = new Ajv({ allErrors: true, jsonPointers: true })
168
- const validateLabware = labwareAjv.compile(generatedSchema)
169
- const ok = validateLabware(toValidate.labwareDefinitions)
170
- if (!ok) {
171
- // eslint-disable-next-line prefer-promise-reject-errors
172
- reject(validateLabware.errors)
173
- }
174
- resolve(toValidate.labwareDefinitions)
175
- })
176
- )
177
-
178
- const validate8 = (toValidate: any): Promise<ProtocolSchemas.ProtocolFileV8> =>
179
- new Promise<ProtocolSchemas.ProtocolStructureV8>((resolve, reject) => {
180
- const protoAjv = new Ajv({ allErrors: true, jsonPointers: true })
181
- const validateProtocol = protoAjv.compile(protocolSchema8)
182
- const valid = validateProtocol(toValidate)
183
- if (!valid) {
184
- // eslint-disable-next-line prefer-promise-reject-errors
185
- reject(validateProtocol.errors)
186
- }
187
- const validatedProtocol = toValidate as ProtocolSchemas.ProtocolStructureV8
188
- resolve(validatedProtocol)
189
- })
190
- .then(protocol =>
191
- Promise.all([
192
- validateCommands8(protocol),
193
- validateCommandAnnotations8(protocol),
194
- validateLiquids8(protocol),
195
- validateLabware8(protocol),
196
- ])
197
- )
198
- .then(() => Promise.resolve(toValidate as ProtocolSchemas.ProtocolFileV8))
199
-
200
- const fakeAjvErrorForBadOTSharedSchema = (
201
- requestedValue: any
202
- ): Ajv.ErrorObject => ({
203
- keyword: 'Invalid protocol schema requested',
204
- dataPath: requestedValue,
205
- schemaPath: '#/properties/$otSharedSchema',
206
- params: {
207
- allowedValues: [
208
- '#/protocol/schemas/8',
209
- '#/protocol/schemas/7',
210
- '#/protocol/schemas/6',
211
- '#/protocol/schemas/5',
212
- '#/protocol/schemas/4',
213
- '#/protocol/schemas/3',
214
- '#/protocol/schemas/2',
215
- '#/protocol/schemas/1',
216
- ],
217
- },
218
- })
219
-
220
- type ProtocolFileSub7 =
221
- | ProtocolSchemas.ProtocolFileV6
222
- | ProtocolSchemas.ProtocolFileV5<{}>
223
- | ProtocolSchemas.ProtocolFileV4<{}>
224
- | ProtocolSchemas.ProtocolFileV3<{}>
225
- | ProtocolSchemas.ProtocolFileV1<{}>
226
-
227
- const validateSub7 = (
228
- toValidate: any,
229
- schemaObj: any
230
- ): Promise<ProtocolFileSub7> =>
231
- new Promise((resolve, reject) => {
232
- const ajv = new Ajv({ allErrors: true, jsonPointers: true })
233
- ajv.addSchema(labwareSchema2)
234
- const validateProtocol = ajv.compile(schemaObj)
235
- const ok = validateProtocol(toValidate)
236
- if (!ok) {
237
- // eslint-disable-next-line prefer-promise-reject-errors
238
- reject(validateProtocol.errors)
239
- }
240
- resolve(toValidate as ProtocolFileSub7)
241
- })
242
-
243
- const validate7 = (toValidate: any): Promise<ProtocolSchemas.ProtocolFileV7> =>
244
- new Promise((resolve, reject) => {
245
- const ajv = new Ajv({ allErrors: true, jsonPointers: true })
246
- ajv.addSchema([commandSchema7, labwareSchema2])
247
- const validateProtocol = ajv.compile(protocolSchema7)
248
- const ok = validateProtocol(toValidate)
249
- if (!ok) {
250
- // eslint-disable-next-line prefer-promise-reject-errors
251
- reject(validateProtocol.errors)
252
- }
253
- resolve(toValidate as ProtocolSchemas.ProtocolFileV7)
254
- })
255
-
256
- // note: rejects with an array of ajv errors
257
- export function validate(
258
- toValidate: any
259
- ): Promise<ProtocolSchemas.JsonProtocolFile> {
260
- // eslint-disable-next-line @typescript-eslint/dot-notation
261
- const requestedProtocolSchema = toValidate['$otSharedSchema']
262
- switch (requestedProtocolSchema) {
263
- case '#/protocol/schemas/8':
264
- return validate8(toValidate)
265
- case '#/protocol/schemas/7':
266
- return validate7(toValidate)
267
- case '#/protocol/schemas/6':
268
- return validateSub7(toValidate, protocolSchema6)
269
- case '#/protocol/schemas/5':
270
- return validateSub7(toValidate, protocolSchema5)
271
- case '#/protocol/schemas/4':
272
- return validateSub7(toValidate, protocolSchema4)
273
- default:
274
- if (!Object.keys(toValidate).includes('$otSharedSchema')) {
275
- const v3SchemaVersion = toValidate.schemaVersion
276
- if (v3SchemaVersion === '3.0.0') {
277
- return validateSub7(toValidate, protocolSchema3)
278
- }
279
- const v1SchemaVersion = toValidate['protocol-schema']
280
- if (v1SchemaVersion === '1.0.0') {
281
- return validateSub7(toValidate, protocolSchema1)
282
- }
283
- }
284
-
285
- return new Promise((resolve, reject) => {
286
- // eslint-disable-next-line prefer-promise-reject-errors
287
- reject([fakeAjvErrorForBadOTSharedSchema(requestedProtocolSchema)])
288
- })
289
- }
290
- }
package/js/schema.ts DELETED
@@ -1,80 +0,0 @@
1
- const NumberType = {
2
- type: 'number',
3
- }
4
- const PositiveNumber = {
5
- type: 'number',
6
- minimum: 0,
7
- }
8
- const LabwareFormats = ['96-standard', '384-standard', 'trough', 'irregular']
9
- // TODO IMMEDIATELY move to labware/flowTypes/
10
- // TODO(mc, 2020-02-21) move to labware/schemas/1.json? delete?
11
- // this only appears to be used in a single test file
12
- // shared-data/js/__tests__/labwareDefSchemaV1.test.js
13
- export const labwareSchemaV1 = {
14
- type: 'object',
15
- required: ['metadata', 'ordering', 'wells'],
16
- additionalProperties: false,
17
- properties: {
18
- metadata: {
19
- type: 'object',
20
- required: ['name', 'format'],
21
- properties: {
22
- name: {
23
- type: 'string',
24
- },
25
- format: {
26
- enum: LabwareFormats,
27
- },
28
- deprecated: {
29
- enum: [true],
30
- },
31
- displayName: {
32
- type: 'string',
33
- },
34
- displayCategory: {
35
- type: 'string',
36
- },
37
- isValidSource: {
38
- enum: [false],
39
- },
40
- isTiprack: {
41
- enum: [true],
42
- },
43
- tipVolume: PositiveNumber,
44
- },
45
- },
46
- ordering: {
47
- type: 'array',
48
- items: {
49
- type: 'array',
50
- items: {
51
- type: 'string',
52
- },
53
- },
54
- },
55
- wells: {
56
- type: 'object',
57
- patternProperties: {
58
- '.*': {
59
- // TODO: use ^[A-Z]+[1-9]+[0-9]*$ (eg A1, AB16, not A03) -- but make sure invalid well keys fail instead of slip past
60
- type: 'object',
61
- required: ['height', 'length', 'width', 'x', 'y', 'z'],
62
- properties: {
63
- height: NumberType,
64
- length: PositiveNumber,
65
- width: PositiveNumber,
66
- x: NumberType,
67
- y: NumberType,
68
- z: NumberType,
69
- // Optional
70
- diameter: PositiveNumber,
71
- // NOTE: presence of diameter indicates a circular well
72
- depth: PositiveNumber,
73
- // TODO Ian 2018-03-12: depth should be required, but is missing in MALDI-plate
74
- 'total-liquid-volume': PositiveNumber,
75
- },
76
- },
77
- },
78
- },
79
- },
80
- }
@@ -1,46 +0,0 @@
1
- const assert = require('assert')
2
- const fs = require('fs')
3
- const path = require('path')
4
- const camelCase = require('lodash/camelCase')
5
- const JSDOM = require('jsdom').JSDOM
6
- const { promisify } = require('util')
7
- const readFile = promisify(fs.readFile)
8
- const writeFile = promisify(fs.writeFile)
9
-
10
- // NOTE: the expected source SVG is an output SVG from Adobe Illustrator
11
- // when using `Save as` or `Save as a Copy` and not `Export`
12
- // Furthermore, the .ai file should contain no groups and all layers
13
- // will be directly translated to layer groups in the JSON output
14
-
15
- const svgPath = process.argv[2]
16
- const buildDir = process.argv[3]
17
-
18
- const USAGE =
19
- 'Expected Params Not Present: (e.g. node ./scripts/generateDeckLayersFromSVG ./path/to/source/svg ./path/to/output/dir)'
20
- assert(svgPath && buildDir, USAGE)
21
-
22
- readFile(svgPath, 'utf8')
23
- .then(data => {
24
- const doc = new JSDOM(data, 'text/xml')
25
- const groups = Array.from(doc.window.document.querySelectorAll('g'))
26
-
27
- let layers = {}
28
- groups.forEach(g => {
29
- const groupId = g.getAttribute('id')
30
- if (groupId && g.hasChildNodes()) {
31
- const features = Array.from(g.querySelectorAll('path'))
32
- const paths = features.map(f => ({
33
- footprint: f.getAttribute('d').replace(/\s| {2}|\r\n|\n|\r/gm, ''), // clean up whitespaces and newlines
34
- }))
35
- layers = { ...layers, [camelCase(groupId)]: paths }
36
- }
37
- })
38
-
39
- const jsonOutput = JSON.stringify(layers)
40
- return writeFile(path.join(buildDir, 'deckLayers.json'), jsonOutput)
41
- })
42
- .then(() => process.exit(0))
43
- .catch(error => {
44
- console.error(error)
45
- process.exit(1)
46
- })
package/js/titleCase.ts DELETED
@@ -1,30 +0,0 @@
1
- const SMALL_WORDS = /\b(?:an?d?|a[st]|because|but|by|en|for|i[fn]|neither|nor|o[fnr]|only|over|per|μL|so|some|tha[tn]|the|to|up|upon|vs?\.?|versus|via|when|with|without|yet)\b/i
2
- const TOKENS = /[^\s:–—-]+|./g
3
- const WHITESPACE = /\s/
4
- const IS_MANUAL_CASE = /.(?=[A-Z]|\..)/
5
- const ALPHANUMERIC_PATTERN = /[A-Za-z0-9\u00C0-\u00FF]/
6
-
7
- export function titleCase(input: string): string {
8
- let result = ''
9
- let m: RegExpExecArray | null
10
-
11
- while ((m = TOKENS.exec(input)) !== null) {
12
- const { 0: token, index } = m
13
-
14
- if (
15
- !IS_MANUAL_CASE.test(token) &&
16
- (!SMALL_WORDS.test(token) ||
17
- index === 0 ||
18
- index + token.length === input.length) &&
19
- (input.charAt(index + token.length) !== ':' ||
20
- WHITESPACE.test(input.charAt(index + token.length + 1)))
21
- ) {
22
- result += token.replace(ALPHANUMERIC_PATTERN, m => m.toUpperCase())
23
- continue
24
- }
25
-
26
- result += token
27
- }
28
-
29
- return result
30
- }