@autofleet/sadot 1.0.5 → 1.0.7
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.
- package/dist/_virtual/_@oxc-project_runtime@0.89.0/helpers/decorate.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.89.0/helpers/decorate.js +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.89.0/helpers/decorateMetadata.cjs +1 -0
- package/dist/_virtual/_@oxc-project_runtime@0.89.0/helpers/decorateMetadata.js +1 -0
- package/dist/_virtual/rolldown_runtime.cjs +1 -0
- package/dist/api/index.cjs +2 -0
- package/dist/api/index.cjs.map +1 -0
- package/dist/api/index.js +2 -12
- package/dist/api/index.js.map +1 -0
- package/dist/api/v1/definition/index.cjs +2 -0
- package/dist/api/v1/definition/index.cjs.map +1 -0
- package/dist/api/v1/definition/index.js +2 -116
- package/dist/api/v1/definition/index.js.map +1 -0
- package/dist/api/v1/definition/validations.cjs +2 -0
- package/dist/api/v1/definition/validations.cjs.map +1 -0
- package/dist/api/v1/definition/validations.js +2 -77
- package/dist/api/v1/definition/validations.js.map +1 -0
- package/dist/api/v1/errors.cjs +2 -0
- package/dist/api/v1/errors.cjs.map +1 -0
- package/dist/api/v1/errors.js +2 -12
- package/dist/api/v1/errors.js.map +1 -0
- package/dist/api/v1/index.cjs +2 -0
- package/dist/api/v1/index.cjs.map +1 -0
- package/dist/api/v1/index.js +2 -13
- package/dist/api/v1/index.js.map +1 -0
- package/dist/api/v1/validator/index.cjs +2 -0
- package/dist/api/v1/validator/index.cjs.map +1 -0
- package/dist/api/v1/validator/index.js +2 -143
- package/dist/api/v1/validator/index.js.map +1 -0
- package/dist/api/v1/validator/validations.cjs +2 -0
- package/dist/api/v1/validator/validations.cjs.map +1 -0
- package/dist/api/v1/validator/validations.js +2 -38
- package/dist/api/v1/validator/validations.js.map +1 -0
- package/dist/errors/index.cjs +3 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.js +3 -66
- package/dist/errors/index.js.map +1 -0
- package/dist/events/index.cjs +2 -0
- package/dist/events/index.cjs.map +1 -0
- package/dist/events/index.js +2 -54
- package/dist/events/index.js.map +1 -0
- package/dist/hooks/enrich.cjs +2 -0
- package/dist/hooks/enrich.cjs.map +1 -0
- package/dist/hooks/enrich.js +2 -198
- package/dist/hooks/enrich.js.map +1 -0
- package/dist/hooks/find.cjs +2 -0
- package/dist/hooks/find.cjs.map +1 -0
- package/dist/hooks/find.js +2 -29
- package/dist/hooks/find.js.map +1 -0
- package/dist/hooks/hooks.cjs +2 -0
- package/dist/hooks/hooks.cjs.map +1 -0
- package/dist/hooks/hooks.js +2 -388
- package/dist/hooks/hooks.js.map +1 -0
- package/dist/hooks/index.cjs +1 -0
- package/dist/hooks/index.js +1 -17
- package/dist/hooks/utils/updateInstanceValues.cjs +2 -0
- package/dist/hooks/utils/updateInstanceValues.cjs.map +1 -0
- package/dist/hooks/utils/updateInstanceValues.js +2 -50
- package/dist/hooks/utils/updateInstanceValues.js.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +19 -0
- package/dist/index.d.ts +18 -12
- package/dist/index.js +2 -67
- package/dist/index.js.map +1 -0
- package/dist/models/CustomFieldDefinition.cjs +2 -0
- package/dist/models/CustomFieldDefinition.cjs.map +1 -0
- package/dist/models/CustomFieldDefinition.js +2 -192
- package/dist/models/CustomFieldDefinition.js.map +1 -0
- package/dist/models/CustomFieldEntries.cjs +2 -0
- package/dist/models/CustomFieldEntries.cjs.map +1 -0
- package/dist/models/CustomFieldEntries.js +2 -123
- package/dist/models/CustomFieldEntries.js.map +1 -0
- package/dist/models/CustomFieldValue.cjs +2 -0
- package/dist/models/CustomFieldValue.cjs.map +1 -0
- package/dist/models/CustomFieldValue.js +2 -151
- package/dist/models/CustomFieldValue.js.map +1 -0
- package/dist/models/CustomValidator.cjs +2 -0
- package/dist/models/CustomValidator.cjs.map +1 -0
- package/dist/models/CustomValidator.js +2 -98
- package/dist/models/CustomValidator.js.map +1 -0
- package/dist/models/index.cjs +2 -0
- package/dist/models/index.cjs.map +1 -0
- package/dist/models/index.js +2 -131
- package/dist/models/index.js.map +1 -0
- package/dist/models/tests/AssociatedTestModel.cjs +2 -0
- package/dist/models/tests/AssociatedTestModel.cjs.map +1 -0
- package/dist/models/tests/AssociatedTestModel.js +2 -71
- package/dist/models/tests/AssociatedTestModel.js.map +1 -0
- package/dist/models/tests/TestModel.cjs +2 -0
- package/dist/models/tests/TestModel.cjs.map +1 -0
- package/dist/models/tests/TestModel.js +2 -69
- package/dist/models/tests/TestModel.js.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs +2 -0
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.cjs.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.js +2 -53
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.js.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextTestModel.cjs +2 -0
- package/dist/models/tests/contextAwareModels/ContextTestModel.cjs.map +1 -0
- package/dist/models/tests/contextAwareModels/ContextTestModel.js +2 -47
- package/dist/models/tests/contextAwareModels/ContextTestModel.js.map +1 -0
- package/dist/repository/definition.cjs +2 -0
- package/dist/repository/definition.cjs.map +1 -0
- package/dist/repository/definition.js +2 -121
- package/dist/repository/definition.js.map +1 -0
- package/dist/repository/entries.cjs +2 -0
- package/dist/repository/entries.cjs.map +1 -0
- package/dist/repository/entries.js +2 -92
- package/dist/repository/entries.js.map +1 -0
- package/dist/repository/utils/formatValues.cjs +2 -0
- package/dist/repository/utils/formatValues.cjs.map +1 -0
- package/dist/repository/utils/formatValues.js +2 -16
- package/dist/repository/utils/formatValues.js.map +1 -0
- package/dist/repository/validator.cjs +2 -0
- package/dist/repository/validator.cjs.map +1 -0
- package/dist/repository/validator.js +2 -69
- package/dist/repository/validator.js.map +1 -0
- package/dist/repository/value.cjs +2 -0
- package/dist/repository/value.cjs.map +1 -0
- package/dist/repository/value.js +2 -124
- package/dist/repository/value.js.map +1 -0
- package/dist/scopes/filter.cjs +2 -0
- package/dist/scopes/filter.cjs.map +1 -0
- package/dist/scopes/filter.d.cts +23 -0
- package/dist/scopes/filter.d.ts +22 -29
- package/dist/scopes/filter.js +2 -75
- package/dist/scopes/filter.js.map +1 -0
- package/dist/scopes/helpers/filter.helpers.cjs +46 -0
- package/dist/scopes/helpers/filter.helpers.cjs.map +1 -0
- package/dist/scopes/helpers/filter.helpers.d.cts +17 -0
- package/dist/scopes/helpers/filter.helpers.d.ts +15 -40
- package/dist/scopes/helpers/filter.helpers.js +25 -183
- package/dist/scopes/helpers/filter.helpers.js.map +1 -0
- package/dist/scopes/index.cjs +1 -0
- package/dist/scopes/index.js +1 -6
- package/dist/types/index.d.cts +44 -0
- package/dist/types/index.d.ts +41 -44
- package/dist/utils/constants/index.cjs +2 -0
- package/dist/utils/constants/index.cjs.map +1 -0
- package/dist/utils/constants/index.d.cts +22 -0
- package/dist/utils/constants/index.d.ts +20 -17
- package/dist/utils/constants/index.js +2 -22
- package/dist/utils/constants/index.js.map +1 -0
- package/dist/utils/db/index.cjs +2 -0
- package/dist/utils/db/index.cjs.map +1 -0
- package/dist/utils/db/index.js +2 -24
- package/dist/utils/db/index.js.map +1 -0
- package/dist/utils/helpers/index.cjs +2 -0
- package/dist/utils/helpers/index.cjs.map +1 -0
- package/dist/utils/helpers/index.d.cts +31 -0
- package/dist/utils/helpers/index.d.ts +28 -23
- package/dist/utils/helpers/index.js +2 -40
- package/dist/utils/helpers/index.js.map +1 -0
- package/dist/utils/init.cjs +2 -0
- package/dist/utils/init.cjs.map +1 -0
- package/dist/utils/init.js +2 -112
- package/dist/utils/init.js.map +1 -0
- package/dist/utils/logger/index.cjs +2 -0
- package/dist/utils/logger/index.cjs.map +1 -0
- package/dist/utils/logger/index.js +2 -42
- package/dist/utils/logger/index.js.map +1 -0
- package/dist/utils/scopeAttributes.cjs +2 -0
- package/dist/utils/scopeAttributes.cjs.map +1 -0
- package/dist/utils/scopeAttributes.js +2 -11
- package/dist/utils/scopeAttributes.js.map +1 -0
- package/dist/utils/validations/index.cjs +2 -0
- package/dist/utils/validations/index.cjs.map +1 -0
- package/dist/utils/validations/index.js +2 -41
- package/dist/utils/validations/index.js.map +1 -0
- package/dist/utils/validations/schema/custom-fields.cjs +2 -0
- package/dist/utils/validations/schema/custom-fields.cjs.map +1 -0
- package/dist/utils/validations/schema/custom-fields.d.cts +7 -0
- package/dist/utils/validations/schema/custom-fields.d.ts +6 -2
- package/dist/utils/validations/schema/custom-fields.js +2 -9
- package/dist/utils/validations/schema/custom-fields.js.map +1 -0
- package/dist/utils/validations/schema/validator-schema.cjs +2 -0
- package/dist/utils/validations/schema/validator-schema.cjs.map +1 -0
- package/dist/utils/validations/schema/validator-schema.js +2 -95
- package/dist/utils/validations/schema/validator-schema.js.map +1 -0
- package/dist/utils/validations/validators/index.cjs +2 -0
- package/dist/utils/validations/validators/index.cjs.map +1 -0
- package/dist/utils/validations/validators/index.js +2 -40
- package/dist/utils/validations/validators/index.js.map +1 -0
- package/dist/utils/validations/validators/select.validator.cjs +2 -0
- package/dist/utils/validations/validators/select.validator.cjs.map +1 -0
- package/dist/utils/validations/validators/select.validator.js +2 -12
- package/dist/utils/validations/validators/select.validator.js.map +1 -0
- package/dist/utils/validations/validators/status.validator.cjs +2 -0
- package/dist/utils/validations/validators/status.validator.cjs.map +1 -0
- package/dist/utils/validations/validators/status.validator.js +2 -15
- package/dist/utils/validations/validators/status.validator.js.map +1 -0
- package/package.json +26 -23
- package/.nvmrc +0 -1
- package/dist/api/index.d.ts +0 -3
- package/dist/api/v1/definition/index.d.ts +0 -3
- package/dist/api/v1/definition/validations.d.ts +0 -2
- package/dist/api/v1/errors.d.ts +0 -4
- package/dist/api/v1/index.d.ts +0 -3
- package/dist/api/v1/validator/index.d.ts +0 -3
- package/dist/api/v1/validator/validations.d.ts +0 -6
- package/dist/errors/index.d.ts +0 -24
- package/dist/events/index.d.ts +0 -5
- package/dist/hooks/create.d.ts +0 -10
- package/dist/hooks/create.js +0 -95
- package/dist/hooks/enrich.d.ts +0 -25
- package/dist/hooks/find.d.ts +0 -1
- package/dist/hooks/hooks.d.ts +0 -17
- package/dist/hooks/index.d.ts +0 -5
- package/dist/hooks/update.d.ts +0 -10
- package/dist/hooks/update.js +0 -49
- package/dist/hooks/utils/updateInstanceValues.d.ts +0 -15
- package/dist/hooks/workaround.d.ts +0 -10
- package/dist/hooks/workaround.js +0 -37
- package/dist/models/CustomFieldDefinition.d.ts +0 -25
- package/dist/models/CustomFieldEntries.d.ts +0 -15
- package/dist/models/CustomFieldValue.d.ts +0 -16
- package/dist/models/CustomValidator.d.ts +0 -17
- package/dist/models/index.d.ts +0 -18
- package/dist/models/tests/AssociatedTestModel.d.ts +0 -12
- package/dist/models/tests/TestModel.d.ts +0 -12
- package/dist/models/tests/contextAwareModels/ContextAwareTestModel.d.ts +0 -10
- package/dist/models/tests/contextAwareModels/ContextTestModel.d.ts +0 -13
- package/dist/repository/definition.d.ts +0 -36
- package/dist/repository/entries.d.ts +0 -13
- package/dist/repository/utils/formatValues.d.ts +0 -3
- package/dist/repository/validator.d.ts +0 -28
- package/dist/repository/value.d.ts +0 -28
- package/dist/scopes/index.d.ts +0 -2
- package/dist/tests/api/test-api.d.ts +0 -2
- package/dist/tests/api/test-api.js +0 -38
- package/dist/tests/functional/searching/index.d.ts +0 -8
- package/dist/tests/functional/searching/index.js +0 -44
- package/dist/tests/helpers/commonHooks.d.ts +0 -6
- package/dist/tests/helpers/commonHooks.js +0 -62
- package/dist/tests/helpers/database-config.d.ts +0 -16
- package/dist/tests/helpers/database-config.js +0 -17
- package/dist/tests/helpers/index.d.ts +0 -7
- package/dist/tests/helpers/index.js +0 -33
- package/dist/tests/mocks/definition.mock.d.ts +0 -48
- package/dist/tests/mocks/definition.mock.js +0 -78
- package/dist/tests/mocks/events.mock.d.ts +0 -4
- package/dist/tests/mocks/events.mock.js +0 -21
- package/dist/tests/mocks/testModel.d.ts +0 -12
- package/dist/tests/mocks/testModel.js +0 -35
- package/dist/types/definition/index.d.ts +0 -25
- package/dist/types/definition/index.js +0 -2
- package/dist/types/entries/index.d.ts +0 -25
- package/dist/types/entries/index.js +0 -2
- package/dist/types/index.js +0 -2
- package/dist/types/value/index.d.ts +0 -15
- package/dist/types/value/index.js +0 -2
- package/dist/utils/db/index.d.ts +0 -4
- package/dist/utils/init.d.ts +0 -7
- package/dist/utils/logger/index.d.ts +0 -3
- package/dist/utils/scopeAttributes.d.ts +0 -2
- package/dist/utils/validations/index.d.ts +0 -8
- package/dist/utils/validations/schema/validator-schema.d.ts +0 -9
- package/dist/utils/validations/type.d.ts +0 -15
- package/dist/utils/validations/type.js +0 -2
- package/dist/utils/validations/validators/index.d.ts +0 -14
- package/dist/utils/validations/validators/select.validator.d.ts +0 -5
- package/dist/utils/validations/validators/status.validator.d.ts +0 -12
- package/src/api/index.ts +0 -10
- package/src/api/v1/definition/index.ts +0 -104
- package/src/api/v1/definition/validations.ts +0 -75
- package/src/api/v1/errors.ts +0 -13
- package/src/api/v1/index.ts +0 -11
- package/src/api/v1/validator/index.ts +0 -141
- package/src/api/v1/validator/validations.ts +0 -38
- package/src/errors/index.ts +0 -70
- package/src/events/index.ts +0 -63
- package/src/hooks/create.ts +0 -81
- package/src/hooks/enrich.ts +0 -255
- package/src/hooks/find.ts +0 -27
- package/src/hooks/hooks.ts +0 -479
- package/src/hooks/index.ts +0 -20
- package/src/hooks/update.ts +0 -55
- package/src/hooks/utils/updateInstanceValues.ts +0 -63
- package/src/hooks/workaround.ts +0 -47
- package/src/index.ts +0 -52
- package/src/models/CustomFieldDefinition.ts +0 -162
- package/src/models/CustomFieldEntries.ts +0 -81
- package/src/models/CustomFieldValue.ts +0 -118
- package/src/models/CustomValidator.ts +0 -78
- package/src/models/index.ts +0 -165
- package/src/models/tests/AssociatedTestModel.ts +0 -57
- package/src/models/tests/TestModel.ts +0 -54
- package/src/models/tests/contextAwareModels/ContextAwareTestModel.ts +0 -43
- package/src/models/tests/contextAwareModels/ContextTestModel.ts +0 -38
- package/src/repository/definition.ts +0 -175
- package/src/repository/entries.ts +0 -88
- package/src/repository/utils/formatValues.ts +0 -14
- package/src/repository/validator.ts +0 -119
- package/src/repository/value.ts +0 -116
- package/src/scopes/filter.ts +0 -100
- package/src/scopes/helpers/filter.helpers.ts +0 -227
- package/src/scopes/index.ts +0 -6
- package/src/tests/api/test-api.ts +0 -40
- package/src/tests/functional/searching/index.ts +0 -39
- package/src/tests/helpers/commonHooks.ts +0 -43
- package/src/tests/helpers/database-config.ts +0 -15
- package/src/tests/helpers/index.ts +0 -35
- package/src/tests/mocks/definition.mock.ts +0 -84
- package/src/tests/mocks/events.mock.ts +0 -21
- package/src/tests/mocks/testModel.ts +0 -37
- package/src/types/definition/index.ts +0 -24
- package/src/types/entries/index.ts +0 -27
- package/src/types/index.ts +0 -52
- package/src/types/value/index.ts +0 -14
- package/src/utils/constants/index.ts +0 -25
- package/src/utils/db/index.ts +0 -21
- package/src/utils/helpers/index.ts +0 -66
- package/src/utils/init.ts +0 -122
- package/src/utils/logger/index.ts +0 -14
- package/src/utils/scopeAttributes.ts +0 -12
- package/src/utils/validations/index.ts +0 -46
- package/src/utils/validations/schema/README.md +0 -93
- package/src/utils/validations/schema/custom-fields.ts +0 -8
- package/src/utils/validations/schema/validator-schema.ts +0 -106
- package/src/utils/validations/type.ts +0 -20
- package/src/utils/validations/validators/index.ts +0 -38
- package/src/utils/validations/validators/select.validator.ts +0 -12
- package/src/utils/validations/validators/status.validator.ts +0 -22
- package/tsconfig.build.json +0 -7
- package/tsconfig.json +0 -16
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validator-schema.js","names":[],"sources":["../../../../src/utils/validations/schema/validator-schema.ts"],"sourcesContent":["import Ajv from 'ajv';\nimport addFormats from 'ajv-formats';\nimport { BadRequest } from '@autofleet/errors';\nimport logger from '../../logger';\nimport type { SchemaObject } from '../../../api/v1/validator/validations';\n\n// Instantiate Ajv for meta-validation\nconst metaValidator = new Ajv({\n allErrors: true,\n strict: false,\n strictTypes: false,\n $data: true, // Enable $data references\n});\naddFormats(metaValidator);\n\n/**\n * Schema for validating JSON Schema objects in custom validators\n * This is a meta-schema to ensure that custom validator schemas are valid Ajv schemas\n */\nconst validatorMetaSchema = {\n type: 'object',\n properties: {\n type: { type: 'string', enum: ['object'] },\n properties: {\n type: 'object',\n properties: {\n before: {\n type: 'object',\n properties: {\n type: { type: 'string', enum: ['object'] },\n properties: { type: 'object' },\n },\n },\n after: {\n type: 'object',\n properties: {\n type: { type: 'string', enum: ['object'] },\n properties: { type: 'object' },\n },\n },\n },\n },\n required: {\n type: 'array',\n items: { type: 'string' },\n },\n if: { type: 'object' },\n then: { type: 'object' },\n else: { type: 'object' },\n },\n required: ['type', 'properties'],\n};\n\n/**\n * Validates that a given schema is a valid Ajv schema\n * This function is used to validate schemas passed to custom validators\n *\n * @param schema The schema to validate\n * @returns true if valid, throws an error if invalid\n */\nexport const validateValidatorSchema = (schema: SchemaObject): boolean => {\n try {\n // First validate the schema structure\n const validateMetaSchema = metaValidator.compile(validatorMetaSchema);\n const isValidStructure = validateMetaSchema(schema);\n\n if (!isValidStructure) {\n const errorDetails = validateMetaSchema.errors?.map((err) =>\n `${(err as unknown as { instancePath: string }).instancePath || ''} ${(err as unknown as { message: string }).message || 'Invalid schema structure'}`).join(', ');\n\n logger.error('Invalid validator schema structure', {\n errors: validateMetaSchema.errors,\n schema,\n });\n\n throw new BadRequest(\n [new Error(`Invalid validator schema structure: ${errorDetails}`)],\n ['Invalid validator schema structure'],\n );\n }\n\n // Then try to compile the schema with Ajv to verify it's a valid JSON Schema\n try {\n metaValidator.compile(schema);\n return true;\n } catch (compileError) {\n logger.error('Failed to compile validator schema', { error: compileError, schema });\n\n throw new BadRequest(\n [new Error(`Failed to compile validator schema: ${(compileError as Error).message}`)],\n ['Invalid validator schema'],\n );\n }\n } catch (error) {\n if (error instanceof BadRequest) {\n throw error;\n }\n\n logger.error('Error validating validator schema', { error, schema });\n throw new BadRequest(\n [new Error(`Error validating validator schema: ${(error as Error).message}`)],\n ['Invalid validator schema'],\n );\n }\n};\n\nexport default validateValidatorSchema;\n"],"mappings":"kIAOA,MAAM,EAAgB,IAAI,EAAI,CAC5B,UAAW,GACX,OAAQ,GACR,YAAa,GACb,MAAO,GACR,CAAC,CACF,EAAW,EAAc,CAMzB,MAAM,EAAsB,CAC1B,KAAM,SACN,WAAY,CACV,KAAM,CAAE,KAAM,SAAU,KAAM,CAAC,SAAS,CAAE,CAC1C,WAAY,CACV,KAAM,SACN,WAAY,CACV,OAAQ,CACN,KAAM,SACN,WAAY,CACV,KAAM,CAAE,KAAM,SAAU,KAAM,CAAC,SAAS,CAAE,CAC1C,WAAY,CAAE,KAAM,SAAU,CAC/B,CACF,CACD,MAAO,CACL,KAAM,SACN,WAAY,CACV,KAAM,CAAE,KAAM,SAAU,KAAM,CAAC,SAAS,CAAE,CAC1C,WAAY,CAAE,KAAM,SAAU,CAC/B,CACF,CACF,CACF,CACD,SAAU,CACR,KAAM,QACN,MAAO,CAAE,KAAM,SAAU,CAC1B,CACD,GAAI,CAAE,KAAM,SAAU,CACtB,KAAM,CAAE,KAAM,SAAU,CACxB,KAAM,CAAE,KAAM,SAAU,CACzB,CACD,SAAU,CAAC,OAAQ,aAAa,CACjC,CASY,EAA2B,GAAkC,CACxE,GAAI,CAEF,IAAM,EAAqB,EAAc,QAAQ,EAAoB,CAGrE,GAAI,CAFqB,EAAmB,EAAO,CAE5B,CACrB,IAAM,EAAe,EAAmB,QAAQ,IAAK,GACnD,GAAI,EAA4C,cAAgB,GAAG,GAAI,EAAuC,SAAW,6BAA6B,CAAC,KAAK,KAAK,CAOnK,MALA,EAAO,MAAM,qCAAsC,CACjD,OAAQ,EAAmB,OAC3B,SACD,CAAC,CAEI,IAAI,EACR,CAAK,MAAM,uCAAuC,IAAe,CAAC,CAClE,CAAC,qCAAqC,CACvC,CAIH,GAAI,CAEF,OADA,EAAc,QAAQ,EAAO,CACtB,SACA,EAAc,CAGrB,MAFA,EAAO,MAAM,qCAAsC,CAAE,MAAO,EAAc,SAAQ,CAAC,CAE7E,IAAI,EACR,CAAK,MAAM,uCAAwC,EAAuB,UAAU,CAAC,CACrF,CAAC,2BAA2B,CAC7B,QAEI,EAAO,CAMd,MALI,aAAiB,EACb,GAGR,EAAO,MAAM,oCAAqC,CAAE,QAAO,SAAQ,CAAC,CAC9D,IAAI,EACR,CAAK,MAAM,sCAAuC,EAAgB,UAAU,CAAC,CAC7E,CAAC,2BAA2B,CAC7B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require(`../../../_virtual/rolldown_runtime.cjs`),t=require(`../../constants/index.cjs`),n=require(`./select.validator.cjs`),r=require(`./status.validator.cjs`);let i=require(`joi`);i=e.__toESM(i);const a={[t.CustomFieldDefinitionType.SELECT]:t.CustomFieldDefinitionType.SELECT,[t.CustomFieldDefinitionType.STATUS]:t.CustomFieldDefinitionType.STATUS},o={[t.CustomFieldDefinitionType.SELECT]:n.validateSelect,[t.CustomFieldDefinitionType.STATUS]:r.validateStatus,[t.CustomFieldDefinitionType.TEXT]:e=>i.default.string().min(0).validate(e),[t.CustomFieldDefinitionType.NUMBER]:e=>i.default.number().strict(!0).validate(e),[t.CustomFieldDefinitionType.BOOLEAN]:e=>i.default.boolean().strict().validate(e),[t.CustomFieldDefinitionType.DATE]:e=>i.default.date().validate(e),[t.CustomFieldDefinitionType.DATETIME]:e=>i.default.date().validate(e),[t.CustomFieldDefinitionType.IMAGE]:e=>i.default.array().min(1).unique().items(i.default.string().uri()).validate(e),[t.CustomFieldDefinitionType.FILE]:e=>i.default.array().min(1).unique().items(i.default.object({name:i.default.string().required(),type:i.default.string(),size:i.default.string(),addedBy:i.default.string().uuid()})).validate(e)};exports.CustomValidationTypes=a,exports.validators=o;
|
|
2
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["CustomValidationTypes: Record<Extract<CustomFieldDefinitionType, 'select' | 'status'>, CustomFieldDefinitionType>","CustomFieldDefinitionType","validators: Validators","validateSelect","validateStatus","Joi"],"sources":["../../../../src/utils/validations/validators/index.ts"],"sourcesContent":["import Joi from 'joi';\nimport { CustomFieldDefinitionType } from '../../constants';\nimport type { Validators } from '../type';\nimport { validateSelect } from './select.validator';\nimport { validateStatus } from './status.validator';\n\ntype CustomValidationTypes = Extract<CustomFieldDefinitionType, 'select' | 'status'>;\n/**\n * Custom field types that must have custom validation.\n * TODO: remove this after moving to schema-based validation\n */\nexport const CustomValidationTypes: Record<Extract<CustomFieldDefinitionType, 'select' | 'status'>, CustomFieldDefinitionType> = {\n [CustomFieldDefinitionType.SELECT]: CustomFieldDefinitionType.SELECT,\n [CustomFieldDefinitionType.STATUS]: CustomFieldDefinitionType.STATUS,\n} as const;\n\n/**\n * Validators for custom fields\n */\nexport const validators: Validators = {\n [CustomFieldDefinitionType.SELECT]: validateSelect,\n [CustomFieldDefinitionType.STATUS]: validateStatus,\n [CustomFieldDefinitionType.TEXT]: (value) => Joi.string().min(0).validate(value),\n [CustomFieldDefinitionType.NUMBER]: (value) => Joi.number().strict(true).validate(value),\n [CustomFieldDefinitionType.BOOLEAN]: (value) => Joi.boolean().strict().validate(value),\n [CustomFieldDefinitionType.DATE]: (value) => Joi.date().validate(value),\n [CustomFieldDefinitionType.DATETIME]: (value) => Joi.date().validate(value),\n [CustomFieldDefinitionType.IMAGE]: (value) => Joi.array().min(1).unique()\n .items(Joi.string().uri())\n .validate(value),\n [CustomFieldDefinitionType.FILE]: (value) => Joi.array().min(1).unique().items(Joi.object({\n name: Joi.string().required(),\n type: Joi.string(),\n size: Joi.string(),\n addedBy: Joi.string().uuid(),\n }))\n .validate(value),\n};\n"],"mappings":"6MAWA,MAAaA,EAAoH,EAC9HC,EAAAA,0BAA0B,QAASA,EAAAA,0BAA0B,QAC7DA,EAAAA,0BAA0B,QAASA,EAAAA,0BAA0B,OAC/D,CAKYC,EAAyB,EACnCD,EAAAA,0BAA0B,QAASE,EAAAA,gBACnCF,EAAAA,0BAA0B,QAASG,EAAAA,gBACnCH,EAAAA,0BAA0B,MAAQ,GAAUI,EAAAA,QAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,EAAM,EAC/EJ,EAAAA,0BAA0B,QAAU,GAAUI,EAAAA,QAAI,QAAQ,CAAC,OAAO,GAAK,CAAC,SAAS,EAAM,EACvFJ,EAAAA,0BAA0B,SAAW,GAAUI,EAAAA,QAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAM,EACrFJ,EAAAA,0BAA0B,MAAQ,GAAUI,EAAAA,QAAI,MAAM,CAAC,SAAS,EAAM,EACtEJ,EAAAA,0BAA0B,UAAY,GAAUI,EAAAA,QAAI,MAAM,CAAC,SAAS,EAAM,EAC1EJ,EAAAA,0BAA0B,OAAS,GAAUI,EAAAA,QAAI,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,CACtE,MAAMA,EAAAA,QAAI,QAAQ,CAAC,KAAK,CAAC,CACzB,SAAS,EAAM,EACjBJ,EAAAA,0BAA0B,MAAQ,GAAUI,EAAAA,QAAI,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,MAAMA,EAAAA,QAAI,OAAO,CACxF,KAAMA,EAAAA,QAAI,QAAQ,CAAC,UAAU,CAC7B,KAAMA,EAAAA,QAAI,QAAQ,CAClB,KAAMA,EAAAA,QAAI,QAAQ,CAClB,QAASA,EAAAA,QAAI,QAAQ,CAAC,MAAM,CAC7B,CAAC,CAAC,CACA,SAAS,EAAM,CACnB"}
|
|
@@ -1,40 +1,2 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validators = exports.CustomValidationTypes = void 0;
|
|
7
|
-
const joi_1 = __importDefault(require("joi"));
|
|
8
|
-
const constants_1 = require("../../constants");
|
|
9
|
-
const select_validator_1 = require("./select.validator");
|
|
10
|
-
const status_validator_1 = require("./status.validator");
|
|
11
|
-
/**
|
|
12
|
-
* Custom field types that must have custom validation.
|
|
13
|
-
* TODO: remove this after moving to schema-based validation
|
|
14
|
-
*/
|
|
15
|
-
exports.CustomValidationTypes = {
|
|
16
|
-
[constants_1.CustomFieldDefinitionType.SELECT]: constants_1.CustomFieldDefinitionType.SELECT,
|
|
17
|
-
[constants_1.CustomFieldDefinitionType.STATUS]: constants_1.CustomFieldDefinitionType.STATUS,
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Validators for custom fields
|
|
21
|
-
*/
|
|
22
|
-
exports.validators = {
|
|
23
|
-
[constants_1.CustomFieldDefinitionType.SELECT]: select_validator_1.validateSelect,
|
|
24
|
-
[constants_1.CustomFieldDefinitionType.STATUS]: status_validator_1.validateStatus,
|
|
25
|
-
[constants_1.CustomFieldDefinitionType.TEXT]: (value) => joi_1.default.string().min(0).validate(value),
|
|
26
|
-
[constants_1.CustomFieldDefinitionType.NUMBER]: (value) => joi_1.default.number().strict(true).validate(value),
|
|
27
|
-
[constants_1.CustomFieldDefinitionType.BOOLEAN]: (value) => joi_1.default.boolean().strict().validate(value),
|
|
28
|
-
[constants_1.CustomFieldDefinitionType.DATE]: (value) => joi_1.default.date().validate(value),
|
|
29
|
-
[constants_1.CustomFieldDefinitionType.DATETIME]: (value) => joi_1.default.date().validate(value),
|
|
30
|
-
[constants_1.CustomFieldDefinitionType.IMAGE]: (value) => joi_1.default.array().min(1).unique()
|
|
31
|
-
.items(joi_1.default.string().uri())
|
|
32
|
-
.validate(value),
|
|
33
|
-
[constants_1.CustomFieldDefinitionType.FILE]: (value) => joi_1.default.array().min(1).unique().items(joi_1.default.object({
|
|
34
|
-
name: joi_1.default.string().required(),
|
|
35
|
-
type: joi_1.default.string(),
|
|
36
|
-
size: joi_1.default.string(),
|
|
37
|
-
addedBy: joi_1.default.string().uuid(),
|
|
38
|
-
}))
|
|
39
|
-
.validate(value),
|
|
40
|
-
};
|
|
1
|
+
import{CustomFieldDefinitionType as e}from"../../constants/index.js";import{validateSelect as t}from"./select.validator.js";import{validateStatus as n}from"./status.validator.js";import r from"joi";const i={[e.SELECT]:e.SELECT,[e.STATUS]:e.STATUS},a={[e.SELECT]:t,[e.STATUS]:n,[e.TEXT]:e=>r.string().min(0).validate(e),[e.NUMBER]:e=>r.number().strict(!0).validate(e),[e.BOOLEAN]:e=>r.boolean().strict().validate(e),[e.DATE]:e=>r.date().validate(e),[e.DATETIME]:e=>r.date().validate(e),[e.IMAGE]:e=>r.array().min(1).unique().items(r.string().uri()).validate(e),[e.FILE]:e=>r.array().min(1).unique().items(r.object({name:r.string().required(),type:r.string(),size:r.string(),addedBy:r.string().uuid()})).validate(e)};export{i as CustomValidationTypes,a as validators};
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["CustomValidationTypes: Record<Extract<CustomFieldDefinitionType, 'select' | 'status'>, CustomFieldDefinitionType>","validators: Validators"],"sources":["../../../../src/utils/validations/validators/index.ts"],"sourcesContent":["import Joi from 'joi';\nimport { CustomFieldDefinitionType } from '../../constants';\nimport type { Validators } from '../type';\nimport { validateSelect } from './select.validator';\nimport { validateStatus } from './status.validator';\n\ntype CustomValidationTypes = Extract<CustomFieldDefinitionType, 'select' | 'status'>;\n/**\n * Custom field types that must have custom validation.\n * TODO: remove this after moving to schema-based validation\n */\nexport const CustomValidationTypes: Record<Extract<CustomFieldDefinitionType, 'select' | 'status'>, CustomFieldDefinitionType> = {\n [CustomFieldDefinitionType.SELECT]: CustomFieldDefinitionType.SELECT,\n [CustomFieldDefinitionType.STATUS]: CustomFieldDefinitionType.STATUS,\n} as const;\n\n/**\n * Validators for custom fields\n */\nexport const validators: Validators = {\n [CustomFieldDefinitionType.SELECT]: validateSelect,\n [CustomFieldDefinitionType.STATUS]: validateStatus,\n [CustomFieldDefinitionType.TEXT]: (value) => Joi.string().min(0).validate(value),\n [CustomFieldDefinitionType.NUMBER]: (value) => Joi.number().strict(true).validate(value),\n [CustomFieldDefinitionType.BOOLEAN]: (value) => Joi.boolean().strict().validate(value),\n [CustomFieldDefinitionType.DATE]: (value) => Joi.date().validate(value),\n [CustomFieldDefinitionType.DATETIME]: (value) => Joi.date().validate(value),\n [CustomFieldDefinitionType.IMAGE]: (value) => Joi.array().min(1).unique()\n .items(Joi.string().uri())\n .validate(value),\n [CustomFieldDefinitionType.FILE]: (value) => Joi.array().min(1).unique().items(Joi.object({\n name: Joi.string().required(),\n type: Joi.string(),\n size: Joi.string(),\n addedBy: Joi.string().uuid(),\n }))\n .validate(value),\n};\n"],"mappings":"sMAWA,MAAaA,EAAoH,EAC9H,EAA0B,QAAS,EAA0B,QAC7D,EAA0B,QAAS,EAA0B,OAC/D,CAKYC,EAAyB,EACnC,EAA0B,QAAS,GACnC,EAA0B,QAAS,GACnC,EAA0B,MAAQ,GAAU,EAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,SAAS,EAAM,EAC/E,EAA0B,QAAU,GAAU,EAAI,QAAQ,CAAC,OAAO,GAAK,CAAC,SAAS,EAAM,EACvF,EAA0B,SAAW,GAAU,EAAI,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAM,EACrF,EAA0B,MAAQ,GAAU,EAAI,MAAM,CAAC,SAAS,EAAM,EACtE,EAA0B,UAAY,GAAU,EAAI,MAAM,CAAC,SAAS,EAAM,EAC1E,EAA0B,OAAS,GAAU,EAAI,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,CACtE,MAAM,EAAI,QAAQ,CAAC,KAAK,CAAC,CACzB,SAAS,EAAM,EACjB,EAA0B,MAAQ,GAAU,EAAI,OAAO,CAAC,IAAI,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAI,OAAO,CACxF,KAAM,EAAI,QAAQ,CAAC,UAAU,CAC7B,KAAM,EAAI,QAAQ,CAClB,KAAM,EAAI,QAAQ,CAClB,QAAS,EAAI,QAAQ,CAAC,MAAM,CAC7B,CAAC,CAAC,CACA,SAAS,EAAM,CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.validator.cjs","names":["validateSelect: Validator<string, string[]>","Joi"],"sources":["../../../../src/utils/validations/validators/select.validator.ts"],"sourcesContent":["import Joi from 'joi';\nimport type { Validator } from '../type';\n\n/**\n * Validate that the value is one of the select values\n */\nexport const validateSelect: Validator<string, string[]> = (\n value,\n selectValues,\n) => (\n Joi.string().allow(null).valid(...selectValues).validate(value)\n);\n"],"mappings":"8FAMA,MAAaA,GACX,EACA,IAEAC,EAAAA,QAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,MAAM,GAAG,EAAa,CAAC,SAAS,EAAM"}
|
|
@@ -1,12 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateSelect = void 0;
|
|
7
|
-
const joi_1 = __importDefault(require("joi"));
|
|
8
|
-
/**
|
|
9
|
-
* Validate that the value is one of the select values
|
|
10
|
-
*/
|
|
11
|
-
const validateSelect = (value, selectValues) => (joi_1.default.string().allow(null).valid(...selectValues).validate(value));
|
|
12
|
-
exports.validateSelect = validateSelect;
|
|
1
|
+
import e from"joi";const t=(t,n)=>e.string().allow(null).valid(...n).validate(t);export{t as validateSelect};
|
|
2
|
+
//# sourceMappingURL=select.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"select.validator.js","names":["validateSelect: Validator<string, string[]>"],"sources":["../../../../src/utils/validations/validators/select.validator.ts"],"sourcesContent":["import Joi from 'joi';\nimport type { Validator } from '../type';\n\n/**\n * Validate that the value is one of the select values\n */\nexport const validateSelect: Validator<string, string[]> = (\n value,\n selectValues,\n) => (\n Joi.string().allow(null).valid(...selectValues).validate(value)\n);\n"],"mappings":"mBAMA,MAAaA,GACX,EACA,IAEA,EAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,MAAM,GAAG,EAAa,CAAC,SAAS,EAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.validator.cjs","names":["validateStatus: Validator<StatusValue, StatusOption[]>","Joi"],"sources":["../../../../src/utils/validations/validators/status.validator.ts"],"sourcesContent":["import Joi from 'joi';\nimport type { Validator } from '../type';\n\ntype StatusColor = string | null; // TODO: Takes from @autofleet/colors ?\ntype StatusValue = string;\ntype StatusOption = {\n value: StatusValue;\n color: StatusColor;\n}\n\n/**\n* Validate that the value is one of the status values\n*/\nexport const validateStatus: Validator<StatusValue, StatusOption[]> = (\n value,\n statusValues,\n) => (\n Joi.string()\n .allow(null)\n .valid(...statusValues.map((statusValue) => statusValue.value))\n .validate(value)\n);\n"],"mappings":"8FAaA,MAAaA,GACX,EACA,IAEAC,EAAAA,QAAI,QAAQ,CACT,MAAM,KAAK,CACX,MAAM,GAAG,EAAa,IAAK,GAAgB,EAAY,MAAM,CAAC,CAC9D,SAAS,EAAM"}
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.validateStatus = void 0;
|
|
7
|
-
const joi_1 = __importDefault(require("joi"));
|
|
8
|
-
/**
|
|
9
|
-
* Validate that the value is one of the status values
|
|
10
|
-
*/
|
|
11
|
-
const validateStatus = (value, statusValues) => (joi_1.default.string()
|
|
12
|
-
.allow(null)
|
|
13
|
-
.valid(...statusValues.map((statusValue) => statusValue.value))
|
|
14
|
-
.validate(value));
|
|
15
|
-
exports.validateStatus = validateStatus;
|
|
1
|
+
import e from"joi";const t=(t,n)=>e.string().allow(null).valid(...n.map(e=>e.value)).validate(t);export{t as validateStatus};
|
|
2
|
+
//# sourceMappingURL=status.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status.validator.js","names":["validateStatus: Validator<StatusValue, StatusOption[]>"],"sources":["../../../../src/utils/validations/validators/status.validator.ts"],"sourcesContent":["import Joi from 'joi';\nimport type { Validator } from '../type';\n\ntype StatusColor = string | null; // TODO: Takes from @autofleet/colors ?\ntype StatusValue = string;\ntype StatusOption = {\n value: StatusValue;\n color: StatusColor;\n}\n\n/**\n* Validate that the value is one of the status values\n*/\nexport const validateStatus: Validator<StatusValue, StatusOption[]> = (\n value,\n statusValues,\n) => (\n Joi.string()\n .allow(null)\n .valid(...statusValues.map((statusValue) => statusValue.value))\n .validate(value)\n);\n"],"mappings":"mBAaA,MAAaA,GACX,EACA,IAEA,EAAI,QAAQ,CACT,MAAM,KAAK,CACX,MAAM,GAAG,EAAa,IAAK,GAAgB,EAAY,MAAM,CAAC,CAC9D,SAAS,EAAM"}
|
package/package.json
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@autofleet/sadot",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"description": "",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md"
|
|
12
|
+
],
|
|
6
13
|
"scripts": {
|
|
7
|
-
"
|
|
8
|
-
"build": "rm -rf dist && tsc",
|
|
14
|
+
"build": "tsdown",
|
|
9
15
|
"linter": "eslint .",
|
|
10
|
-
"test": "
|
|
11
|
-
"test-debug": "node --inspect-brk node_modules/.bin/
|
|
12
|
-
"coverage": "
|
|
16
|
+
"test": "vitest",
|
|
17
|
+
"test-debug": "node --inspect-brk node_modules/.bin/vitest --testTimeout=10000000",
|
|
18
|
+
"coverage": "vitest --coverage",
|
|
13
19
|
"build-to-local-repo": "node --run build && cp -r dist/* ../$REPO/node_modules/$npm_package_name/dist",
|
|
14
|
-
"
|
|
15
|
-
"watch": "npm-watch build-to-local-repo",
|
|
16
|
-
"publish-dev": "node --run build && npm publish --tag dev"
|
|
20
|
+
"watch": "npm-watch build-to-local-repo"
|
|
17
21
|
},
|
|
18
22
|
"watch": {
|
|
19
23
|
"build-to-local-repo": {
|
|
@@ -28,37 +32,36 @@
|
|
|
28
32
|
}
|
|
29
33
|
},
|
|
30
34
|
"dependencies": {
|
|
31
|
-
"@autofleet/common-types": "^4.
|
|
32
|
-
"@autofleet/events": "^5.2.
|
|
35
|
+
"@autofleet/common-types": "^4.58.0",
|
|
36
|
+
"@autofleet/events": "^5.2.7",
|
|
33
37
|
"ajv": "^8.12.0",
|
|
34
38
|
"ajv-errors": "^3.0.0",
|
|
35
39
|
"ajv-formats": "^3.0.1",
|
|
36
40
|
"http-status-codes": "^2.3.0",
|
|
37
41
|
"joi": "^17.7.0",
|
|
38
|
-
"pg": "^8.
|
|
42
|
+
"pg": "^8.16.3",
|
|
39
43
|
"reflect-metadata": "^0.1.13",
|
|
40
|
-
"sequelize": "^6.
|
|
41
|
-
"sequelize-typescript": "^2.1.
|
|
44
|
+
"sequelize": "^6.37.7",
|
|
45
|
+
"sequelize-typescript": "^2.1.6"
|
|
42
46
|
},
|
|
43
47
|
"devDependencies": {
|
|
44
|
-
"@autofleet/errors": "^3.
|
|
45
|
-
"@autofleet/logger": "^4.2.
|
|
46
|
-
"@autofleet/node-common": "^4.
|
|
47
|
-
"@autofleet/zehut": "^4.0
|
|
48
|
+
"@autofleet/errors": "^3.1.16",
|
|
49
|
+
"@autofleet/logger": "^4.2.23",
|
|
50
|
+
"@autofleet/node-common": "^4.1.10",
|
|
51
|
+
"@autofleet/zehut": "^4.4.0",
|
|
48
52
|
"@types/express": "^4.17.17",
|
|
49
|
-
"@types/jest": "^29.5.13",
|
|
50
53
|
"@typescript-eslint/eslint-plugin": "^7.18.0",
|
|
51
54
|
"@typescript-eslint/parser": "^7.18.0",
|
|
55
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
52
56
|
"eslint": "^8.57.0",
|
|
53
57
|
"eslint-config-airbnb-base": "^15.0.0",
|
|
54
58
|
"eslint-plugin-import": "^2.22.1",
|
|
55
59
|
"express": "^4.21.2",
|
|
56
|
-
"jest": "^29.7.0",
|
|
57
60
|
"npm-watch": "^0.11.0",
|
|
58
61
|
"supertest": "^7.0.0",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
+
"tsdown": "^0.15.2",
|
|
63
|
+
"typescript": "^5.9.2",
|
|
64
|
+
"vitest": "^3.2.4"
|
|
62
65
|
},
|
|
63
66
|
"peerDependencies": {
|
|
64
67
|
"@autofleet/errors": "^3",
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
22.9.0
|
package/dist/api/index.d.ts
DELETED
package/dist/api/v1/errors.d.ts
DELETED
package/dist/api/v1/index.d.ts
DELETED
package/dist/errors/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { BadRequest } from '@autofleet/errors';
|
|
2
|
-
import type { ValidationError } from 'joi';
|
|
3
|
-
import type { EntriesValidationError } from '../types/entries';
|
|
4
|
-
export declare class MissingRequiredCustomFieldError extends BadRequest {
|
|
5
|
-
constructor(missingFields: string[]);
|
|
6
|
-
}
|
|
7
|
-
export declare class UnsupportedCustomFieldTypeError extends BadRequest {
|
|
8
|
-
constructor(fieldType: string);
|
|
9
|
-
}
|
|
10
|
-
export declare class UnsupportedCustomValidationError extends BadRequest {
|
|
11
|
-
constructor(fieldType: string);
|
|
12
|
-
}
|
|
13
|
-
export declare class InvalidFieldTypeError extends BadRequest {
|
|
14
|
-
constructor(fieldType: string);
|
|
15
|
-
}
|
|
16
|
-
export declare class InvalidValueError extends BadRequest {
|
|
17
|
-
constructor(value: any, fieldDefinitionName: string, joiValidationError: ValidationError);
|
|
18
|
-
}
|
|
19
|
-
export declare class InvalidEntriesError extends BadRequest {
|
|
20
|
-
constructor(modelId: string, validationErrors: EntriesValidationError[]);
|
|
21
|
-
}
|
|
22
|
-
export declare class MissingDefinitionError extends BadRequest {
|
|
23
|
-
constructor(fieldNames: string[]);
|
|
24
|
-
}
|
package/dist/events/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import Events from '@autofleet/events';
|
|
2
|
-
import type { CustomFieldDefinition, CustomFieldEntries, CustomFieldValue, CustomValidator } from '../models';
|
|
3
|
-
declare const events: Events;
|
|
4
|
-
export declare const sendDimEvent: (instance: CustomFieldDefinition | CustomFieldValue | CustomFieldEntries | CustomValidator) => void;
|
|
5
|
-
export default events;
|
package/dist/hooks/create.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CustomFieldOptions, ModelOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* A hook to create the custom fields when updating a model (more then one instance).
|
|
4
|
-
*/
|
|
5
|
-
export declare const beforeBulkCreate: (options: any) => void;
|
|
6
|
-
/**
|
|
7
|
-
* A hook to create the custom fields when updating a model instance.
|
|
8
|
-
* TODO - cleanup if update fail
|
|
9
|
-
*/
|
|
10
|
-
export declare const beforeCreate: (scopeAttributes: string[], modelOptions?: ModelOptions, sadotOptions?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => (instance: any, options: any) => Promise<void>;
|
package/dist/hooks/create.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.beforeCreate = exports.beforeBulkCreate = void 0;
|
|
30
|
-
const logger_1 = __importDefault(require("../utils/logger"));
|
|
31
|
-
const DefinitionRepo = __importStar(require("../repository/definition"));
|
|
32
|
-
const errors_1 = require("../errors");
|
|
33
|
-
const scopeAttributes_1 = __importDefault(require("../utils/scopeAttributes"));
|
|
34
|
-
const updateInstanceValues_1 = __importDefault(require("./utils/updateInstanceValues"));
|
|
35
|
-
/**
|
|
36
|
-
* A hook to create the custom fields when updating a model (more then one instance).
|
|
37
|
-
*/
|
|
38
|
-
const beforeBulkCreate = (options) => {
|
|
39
|
-
// This will activate the beforeCreate hook on each updating instance.
|
|
40
|
-
// eslint-disable-next-line no-param-reassign
|
|
41
|
-
options.individualHooks = true;
|
|
42
|
-
};
|
|
43
|
-
exports.beforeBulkCreate = beforeBulkCreate;
|
|
44
|
-
/**
|
|
45
|
-
* A hook to create the custom fields when updating a model instance.
|
|
46
|
-
* TODO - cleanup if update fail
|
|
47
|
-
*/
|
|
48
|
-
const beforeCreate = (scopeAttributes, modelOptions = {}, sadotOptions = { useCustomFieldsEntries: false }) => async (instance, options) => {
|
|
49
|
-
logger_1.default.debug('sadot - before create hook');
|
|
50
|
-
const { fields } = options;
|
|
51
|
-
const { include, useEntityIdFromInclude } = modelOptions;
|
|
52
|
-
const modelType = instance.constructor.name;
|
|
53
|
-
const identifiers = (0, scopeAttributes_1.default)(instance, scopeAttributes);
|
|
54
|
-
const where = {
|
|
55
|
-
modelType,
|
|
56
|
-
disabled: false,
|
|
57
|
-
...(!useEntityIdFromInclude && { entityId: identifiers }),
|
|
58
|
-
};
|
|
59
|
-
const fieldDefinitions = await DefinitionRepo.findAll(where, { withDisabled: false, transaction: options.transaction, include: include?.(identifiers) });
|
|
60
|
-
const requiredFieldsNames = Array.from(new Set(fieldDefinitions.filter(({ required }) => required).map(({ name }) => name)));
|
|
61
|
-
const fieldsWithDefaultValue = fieldDefinitions.filter((def) => ![null, undefined].includes(def.defaultValue));
|
|
62
|
-
if (fieldsWithDefaultValue.length) {
|
|
63
|
-
// eslint-disable-next-line no-param-reassign
|
|
64
|
-
instance.customFields || (instance.customFields = {});
|
|
65
|
-
fieldsWithDefaultValue.filter((def) => (instance.customFields?.[def.name] === undefined)).forEach(({ name, defaultValue }) => {
|
|
66
|
-
// eslint-disable-next-line no-param-reassign
|
|
67
|
-
instance.customFields[name] = defaultValue;
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
const { customFields } = instance;
|
|
71
|
-
const fieldsNames = Object.keys(customFields ?? {});
|
|
72
|
-
const missingFields = requiredFieldsNames.filter((name) => !fieldsNames.includes(name));
|
|
73
|
-
if (missingFields?.length) {
|
|
74
|
-
throw new errors_1.MissingRequiredCustomFieldError(missingFields);
|
|
75
|
-
}
|
|
76
|
-
const customFieldsIdx = fields.indexOf('customFields');
|
|
77
|
-
if (customFieldsIdx === -1 || !customFields || !Object.keys(customFields).length) {
|
|
78
|
-
// After checking for required fields and fields with default values, and we have no custom fields.
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
await (0, updateInstanceValues_1.default)({
|
|
82
|
-
modelId: instance.id,
|
|
83
|
-
modelType,
|
|
84
|
-
identifiers,
|
|
85
|
-
customFields,
|
|
86
|
-
options: {
|
|
87
|
-
useCustomFieldsEntries: sadotOptions.useCustomFieldsEntries,
|
|
88
|
-
transaction: options.transaction,
|
|
89
|
-
modelOptions,
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
// eslint-disable-next-line no-param-reassign
|
|
93
|
-
fields.splice(customFieldsIdx, 1);
|
|
94
|
-
};
|
|
95
|
-
exports.beforeCreate = beforeCreate;
|
package/dist/hooks/enrich.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type CustomFieldValue from '../models/CustomFieldValue';
|
|
2
|
-
import type { CustomFieldOptions, ModelOptions, TransactionOptions } from '../types';
|
|
3
|
-
type SupportedHookTypes = 'afterFind' | 'afterCreate' | 'afterUpdate';
|
|
4
|
-
type CustomFieldEntries = Record<string, any>;
|
|
5
|
-
interface GetValuesGroupByInstanceResponse {
|
|
6
|
-
[modelId: string]: CustomFieldValue[];
|
|
7
|
-
}
|
|
8
|
-
interface GetCustomFieldEntriesByInstanceIdResponse {
|
|
9
|
-
[modelId: string]: CustomFieldEntries;
|
|
10
|
-
}
|
|
11
|
-
export declare const getCustomFieldEntriesByInstanceId: ({ instancesIds, options, sadotOptions, }: {
|
|
12
|
-
instancesIds: string[];
|
|
13
|
-
options?: TransactionOptions;
|
|
14
|
-
sadotOptions: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>;
|
|
15
|
-
}) => Promise<GetCustomFieldEntriesByInstanceIdResponse>;
|
|
16
|
-
export declare const getValuesGroupByInstance: ({ instancesIds, options, sadotOptions, }: {
|
|
17
|
-
instancesIds: string[];
|
|
18
|
-
options?: TransactionOptions;
|
|
19
|
-
sadotOptions: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>;
|
|
20
|
-
}) => Promise<GetValuesGroupByInstanceResponse>;
|
|
21
|
-
/**
|
|
22
|
-
* A hook to attach the custom fields when fetching a model instances.
|
|
23
|
-
*/
|
|
24
|
-
declare const enrichResults: (modelType: string, scopeAttributes: string[], hookType?: SupportedHookTypes, modelOptions?: ModelOptions, sadotOptions?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => (instancesOrInstance: any | any[], options: TransactionOptions) => Promise<void>;
|
|
25
|
-
export default enrichResults;
|
package/dist/hooks/find.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const beforeFind: (scopeAttributes: string[]) => (options: any) => void;
|
package/dist/hooks/hooks.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CustomFieldOptions, ModelOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* Hook to handle validation and custom fields during creation
|
|
4
|
-
*/
|
|
5
|
-
export declare const beforeCreate: (scopeAttributes: string[], modelOptions?: ModelOptions, sadotOptions?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => (instance: any, options: any) => Promise<void>;
|
|
6
|
-
/**
|
|
7
|
-
* Hook to handle validation and custom fields during update
|
|
8
|
-
*/
|
|
9
|
-
export declare const beforeUpdate: (scopeAttributes: string[], modelOptions?: ModelOptions, sadotOptions?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => (instance: any, options: any) => Promise<void>;
|
|
10
|
-
/**
|
|
11
|
-
* Hook to enable individual hooks for bulk create operations
|
|
12
|
-
*/
|
|
13
|
-
export declare const beforeBulkCreate: (options: any) => void;
|
|
14
|
-
/**
|
|
15
|
-
* Hook to enable individual hooks for bulk update operations
|
|
16
|
-
*/
|
|
17
|
-
export declare const beforeBulkUpdate: (options: any) => void;
|
package/dist/hooks/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import enrichResults from './enrich';
|
|
2
|
-
import { beforeFind } from './find';
|
|
3
|
-
import workaround from './workaround';
|
|
4
|
-
import { beforeCreate, beforeUpdate, beforeBulkCreate, beforeBulkUpdate } from './hooks';
|
|
5
|
-
export { enrichResults, beforeFind, workaround, beforeCreate, beforeUpdate, beforeBulkCreate, beforeBulkUpdate, };
|
package/dist/hooks/update.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CustomFieldOptions, ModelOptions } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* A hook to update the custom fields when updating a model (more then one instance).
|
|
4
|
-
*/
|
|
5
|
-
export declare const beforeBulkUpdate: (options: any) => void;
|
|
6
|
-
/**
|
|
7
|
-
* A hook to update the custom fields when updating a model instance.
|
|
8
|
-
* TODO - cleanup if update fail
|
|
9
|
-
*/
|
|
10
|
-
export declare const beforeUpdate: (scopeAttributes: string[], modelOptions?: ModelOptions, sadotOptions?: Pick<CustomFieldOptions, 'useCustomFieldsEntries'>) => (instance: any, options: any) => Promise<void>;
|
package/dist/hooks/update.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.beforeUpdate = exports.beforeBulkUpdate = void 0;
|
|
7
|
-
const logger_1 = __importDefault(require("../utils/logger"));
|
|
8
|
-
const scopeAttributes_1 = __importDefault(require("../utils/scopeAttributes"));
|
|
9
|
-
const updateInstanceValues_1 = __importDefault(require("./utils/updateInstanceValues"));
|
|
10
|
-
/**
|
|
11
|
-
* A hook to update the custom fields when updating a model (more then one instance).
|
|
12
|
-
*/
|
|
13
|
-
const beforeBulkUpdate = (options) => {
|
|
14
|
-
// This will activate the beforeUpdate hook on each updating instance.
|
|
15
|
-
// eslint-disable-next-line no-param-reassign
|
|
16
|
-
options.individualHooks = true;
|
|
17
|
-
};
|
|
18
|
-
exports.beforeBulkUpdate = beforeBulkUpdate;
|
|
19
|
-
/**
|
|
20
|
-
* A hook to update the custom fields when updating a model instance.
|
|
21
|
-
* TODO - cleanup if update fail
|
|
22
|
-
*/
|
|
23
|
-
const beforeUpdate = (scopeAttributes, modelOptions = {}, sadotOptions = { useCustomFieldsEntries: false }) => async (instance, options) => {
|
|
24
|
-
logger_1.default.debug('sadot - before update hook');
|
|
25
|
-
const { fields } = options;
|
|
26
|
-
const modelType = instance.constructor.name;
|
|
27
|
-
const identifiers = (0, scopeAttributes_1.default)(instance, scopeAttributes);
|
|
28
|
-
const customFieldsIdx = fields.indexOf('customFields');
|
|
29
|
-
if (customFieldsIdx > -1) {
|
|
30
|
-
const { customFields } = instance;
|
|
31
|
-
if (!Object.keys(customFields).length) {
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
await (0, updateInstanceValues_1.default)({
|
|
35
|
-
modelId: instance.id,
|
|
36
|
-
modelType,
|
|
37
|
-
identifiers,
|
|
38
|
-
customFields,
|
|
39
|
-
options: {
|
|
40
|
-
useCustomFieldsEntries: sadotOptions.useCustomFieldsEntries,
|
|
41
|
-
transaction: options.transaction,
|
|
42
|
-
modelOptions,
|
|
43
|
-
},
|
|
44
|
-
});
|
|
45
|
-
// eslint-disable-next-line no-param-reassign
|
|
46
|
-
fields.splice(customFieldsIdx, 1);
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
exports.beforeUpdate = beforeUpdate;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { Transaction } from 'sequelize';
|
|
2
|
-
import type { ModelOptions } from '../../types';
|
|
3
|
-
interface UpdateInstanceValuesParams {
|
|
4
|
-
modelId: string;
|
|
5
|
-
modelType: string;
|
|
6
|
-
identifiers: string[];
|
|
7
|
-
customFields: Record<string, any>;
|
|
8
|
-
options?: {
|
|
9
|
-
transaction?: Transaction;
|
|
10
|
-
modelOptions?: ModelOptions;
|
|
11
|
-
useCustomFieldsEntries?: boolean;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
declare const updateInstanceValues: ({ modelId, modelType, identifiers, customFields, options, }: UpdateInstanceValuesParams) => Promise<void>;
|
|
15
|
-
export default updateInstanceValues;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Workaround to a bug in sequelize.🐛
|
|
3
|
-
*
|
|
4
|
-
* **afterFind hook** isn't working on nested (included) models.
|
|
5
|
-
* The solution here is to add a global afterFind hook,
|
|
6
|
-
* which manually calls the afterFind hook of each model, recursively
|
|
7
|
-
* https://github.com/sequelize/sequelize/issues/4627
|
|
8
|
-
*/
|
|
9
|
-
declare const handleChildrenAfterFindHook: (instances: any, options: any, level?: number) => any;
|
|
10
|
-
export default handleChildrenAfterFindHook;
|
package/dist/hooks/workaround.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Workaround to a bug in sequelize.🐛
|
|
4
|
-
*
|
|
5
|
-
* **afterFind hook** isn't working on nested (included) models.
|
|
6
|
-
* The solution here is to add a global afterFind hook,
|
|
7
|
-
* which manually calls the afterFind hook of each model, recursively
|
|
8
|
-
* https://github.com/sequelize/sequelize/issues/4627
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
const handleChildrenAfterFindHook = async (instances, options, level = 0) => {
|
|
12
|
-
if (!instances)
|
|
13
|
-
return Promise.resolve();
|
|
14
|
-
if (Array.isArray(instances)) {
|
|
15
|
-
return Promise.all(instances.map((instance) => {
|
|
16
|
-
const { options: instanceOptions } = instance.constructor;
|
|
17
|
-
return handleChildrenAfterFindHook(instance, instanceOptions, level);
|
|
18
|
-
}));
|
|
19
|
-
}
|
|
20
|
-
const instance = instances;
|
|
21
|
-
const { constructor } = instance;
|
|
22
|
-
/**
|
|
23
|
-
* Root model will have already run their "afterFind" hook.
|
|
24
|
-
* Only run children "afterFind" hooks.
|
|
25
|
-
*/
|
|
26
|
-
if (level >= 1) {
|
|
27
|
-
await constructor.runHooks('afterFind', instance, options);
|
|
28
|
-
}
|
|
29
|
-
const { associations } = constructor;
|
|
30
|
-
const associatedNames = Object.keys(instance).filter((attribute) => Object.keys(associations).includes(attribute));
|
|
31
|
-
if (associatedNames.length) {
|
|
32
|
-
const childInstances = associatedNames.map((name) => instance[name]);
|
|
33
|
-
return handleChildrenAfterFindHook(childInstances, options, level + 1);
|
|
34
|
-
}
|
|
35
|
-
return Promise.resolve();
|
|
36
|
-
};
|
|
37
|
-
exports.default = handleChildrenAfterFindHook;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Model } from 'sequelize-typescript';
|
|
2
|
-
import { CustomFieldDefinitionType } from '../utils/constants';
|
|
3
|
-
import { CustomFieldValue } from '.';
|
|
4
|
-
declare class CustomFieldDefinition extends Model {
|
|
5
|
-
id: string;
|
|
6
|
-
name: string;
|
|
7
|
-
displayName?: string;
|
|
8
|
-
fieldType: CustomFieldDefinitionType;
|
|
9
|
-
validation?: any;
|
|
10
|
-
entityId: string; /** Client association entity id */
|
|
11
|
-
entityType: string; /** Client association entity type (demand source / fleet / etc.) */
|
|
12
|
-
modelType: string; /** Model type. e.g. Vehicle / StopPoint / etc. */
|
|
13
|
-
description?: string;
|
|
14
|
-
required?: boolean;
|
|
15
|
-
disabled?: boolean;
|
|
16
|
-
defaultValue?: any;
|
|
17
|
-
createdAt?: Date;
|
|
18
|
-
updatedAt?: Date;
|
|
19
|
-
deletedAt?: Date;
|
|
20
|
-
blockEditingFromUI: boolean;
|
|
21
|
-
values: CustomFieldValue[];
|
|
22
|
-
static displayNameDefaultValue(instance: CustomFieldDefinition): void;
|
|
23
|
-
static afterSaveHandler(instance: CustomFieldDefinition, options: any): void;
|
|
24
|
-
}
|
|
25
|
-
export default CustomFieldDefinition;
|