@contember/schema-utils 2.1.0-alpha.30 → 2.1.0-alpha.36
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/package.json +11 -6
- package/src/acl/AllowAllPermissionFactory.ts +1 -1
- package/src/acl/PredicateDefinitionProcessor.ts +5 -7
- package/src/dataUtils.ts +1 -1
- package/src/definition-generator/AclDefinitionCodeGenerator.ts +7 -8
- package/src/definition-generator/DefinitionCodeGenerator.ts +8 -14
- package/src/definition-generator/DefinitionNamingConventions.ts +50 -1
- package/src/index.ts +2 -2
- package/src/lax/LaxSchemaConverter.ts +0 -4
- package/src/lax/schema.ts +4 -1
- package/src/model/modelUtils.ts +2 -4
- package/src/schemaChecksum.ts +0 -1
- package/src/schemaFilter.ts +1 -1
- package/src/type-schema/acl.ts +16 -13
- package/src/type-schema/actions.ts +0 -2
- package/src/type-schema/condition.ts +25 -23
- package/src/type-schema/model.ts +10 -8
- package/src/type-schema/validation.ts +5 -4
- package/src/type-schema/where.ts +11 -9
- package/src/utils/deepCompare.ts +1 -1
- package/src/utils/printJsValue.ts +23 -25
- package/src/validation/AclValidator.ts +0 -2
- package/src/validation/ActionsValidator.ts +7 -7
- package/src/validation/MembershipResolver.ts +0 -3
- package/src/validation/ModelValidator.ts +43 -32
- package/src/validation/SchemaValidator.ts +7 -6
- package/src/validation/ValidationValidator.ts +1 -3
- package/src/validation/errors.ts +0 -3
- package/tests/cases/unit/conditionSchema.test.ts +1 -2
- package/tests/cases/unit/deepCompare.test.ts +2 -3
- package/tests/cases/unit/laxSchemaConverter.test.ts +0 -4
- package/tests/cases/unit/membershipResolver.test.ts +88 -60
- package/tests/cases/unit/modelSchema.test.ts +4 -4
- package/tests/cases/unit/modelValidator.test.ts +0 -1
- package/tests/cases/unit/printJsvalue.test.ts +11 -7
- package/tests/cases/unit/whereSchema.test.ts +19 -18
- package/dist/development/index.cjs +0 -110
- package/dist/development/index.cjs.map +0 -1
- package/dist/development/index.js +0 -94
- package/dist/development/index.js.map +0 -1
- package/dist/development/src/acl/AllowAllPermissionFactory.cjs +0 -42
- package/dist/development/src/acl/AllowAllPermissionFactory.cjs.map +0 -1
- package/dist/development/src/acl/AllowAllPermissionFactory.js +0 -42
- package/dist/development/src/acl/AllowAllPermissionFactory.js.map +0 -1
- package/dist/development/src/acl/PredicateDefinitionProcessor.cjs +0 -71
- package/dist/development/src/acl/PredicateDefinitionProcessor.cjs.map +0 -1
- package/dist/development/src/acl/PredicateDefinitionProcessor.js +0 -71
- package/dist/development/src/acl/PredicateDefinitionProcessor.js.map +0 -1
- package/dist/development/src/acl/schemaUtils.cjs +0 -11
- package/dist/development/src/acl/schemaUtils.cjs.map +0 -1
- package/dist/development/src/acl/schemaUtils.js +0 -11
- package/dist/development/src/acl/schemaUtils.js.map +0 -1
- package/dist/development/src/dataUtils.cjs +0 -59
- package/dist/development/src/dataUtils.cjs.map +0 -1
- package/dist/development/src/dataUtils.js +0 -59
- package/dist/development/src/dataUtils.js.map +0 -1
- package/dist/development/src/definition-generator/AclDefinitionCodeGenerator.cjs +0 -117
- package/dist/development/src/definition-generator/AclDefinitionCodeGenerator.cjs.map +0 -1
- package/dist/development/src/definition-generator/AclDefinitionCodeGenerator.js +0 -117
- package/dist/development/src/definition-generator/AclDefinitionCodeGenerator.js.map +0 -1
- package/dist/development/src/definition-generator/DefinitionCodeGenerator.cjs +0 -218
- package/dist/development/src/definition-generator/DefinitionCodeGenerator.cjs.map +0 -1
- package/dist/development/src/definition-generator/DefinitionCodeGenerator.js +0 -218
- package/dist/development/src/definition-generator/DefinitionCodeGenerator.js.map +0 -1
- package/dist/development/src/definition-generator/DefinitionNamingConventions.cjs +0 -19
- package/dist/development/src/definition-generator/DefinitionNamingConventions.cjs.map +0 -1
- package/dist/development/src/definition-generator/DefinitionNamingConventions.js +0 -19
- package/dist/development/src/definition-generator/DefinitionNamingConventions.js.map +0 -1
- package/dist/development/src/definition-generator/TsDefinitionGenerator.cjs +0 -17
- package/dist/development/src/definition-generator/TsDefinitionGenerator.cjs.map +0 -1
- package/dist/development/src/definition-generator/TsDefinitionGenerator.js +0 -17
- package/dist/development/src/definition-generator/TsDefinitionGenerator.js.map +0 -1
- package/dist/development/src/lax/LaxSchemaConverter.cjs +0 -202
- package/dist/development/src/lax/LaxSchemaConverter.cjs.map +0 -1
- package/dist/development/src/lax/LaxSchemaConverter.js +0 -202
- package/dist/development/src/lax/LaxSchemaConverter.js.map +0 -1
- package/dist/development/src/lax/schema.cjs +0 -70
- package/dist/development/src/lax/schema.cjs.map +0 -1
- package/dist/development/src/lax/schema.js +0 -53
- package/dist/development/src/lax/schema.js.map +0 -1
- package/dist/development/src/model/NamingConventions.cjs +0 -28
- package/dist/development/src/model/NamingConventions.cjs.map +0 -1
- package/dist/development/src/model/NamingConventions.js +0 -28
- package/dist/development/src/model/NamingConventions.js.map +0 -1
- package/dist/development/src/model/modelUtils.cjs +0 -231
- package/dist/development/src/model/modelUtils.cjs.map +0 -1
- package/dist/development/src/model/modelUtils.js +0 -231
- package/dist/development/src/model/modelUtils.js.map +0 -1
- package/dist/development/src/model/resolveDefaultColumnType.cjs +0 -30
- package/dist/development/src/model/resolveDefaultColumnType.cjs.map +0 -1
- package/dist/development/src/model/resolveDefaultColumnType.js +0 -30
- package/dist/development/src/model/resolveDefaultColumnType.js.map +0 -1
- package/dist/development/src/schemaChecksum.cjs +0 -9
- package/dist/development/src/schemaChecksum.cjs.map +0 -1
- package/dist/development/src/schemaChecksum.js +0 -9
- package/dist/development/src/schemaChecksum.js.map +0 -1
- package/dist/development/src/schemaFilter.cjs +0 -24
- package/dist/development/src/schemaFilter.cjs.map +0 -1
- package/dist/development/src/schemaFilter.js +0 -24
- package/dist/development/src/schemaFilter.js.map +0 -1
- package/dist/development/src/schemaNormalizer.cjs +0 -72
- package/dist/development/src/schemaNormalizer.cjs.map +0 -1
- package/dist/development/src/schemaNormalizer.js +0 -72
- package/dist/development/src/schemaNormalizer.js.map +0 -1
- package/dist/development/src/type-schema/acl.cjs +0 -146
- package/dist/development/src/type-schema/acl.cjs.map +0 -1
- package/dist/development/src/type-schema/acl.js +0 -129
- package/dist/development/src/type-schema/acl.js.map +0 -1
- package/dist/development/src/type-schema/actions.cjs +0 -88
- package/dist/development/src/type-schema/actions.cjs.map +0 -1
- package/dist/development/src/type-schema/actions.js +0 -71
- package/dist/development/src/type-schema/actions.js.map +0 -1
- package/dist/development/src/type-schema/condition.cjs +0 -92
- package/dist/development/src/type-schema/condition.cjs.map +0 -1
- package/dist/development/src/type-schema/condition.js +0 -75
- package/dist/development/src/type-schema/condition.js.map +0 -1
- package/dist/development/src/type-schema/model.cjs +0 -219
- package/dist/development/src/type-schema/model.cjs.map +0 -1
- package/dist/development/src/type-schema/model.js +0 -203
- package/dist/development/src/type-schema/model.js.map +0 -1
- package/dist/development/src/type-schema/settings.cjs +0 -34
- package/dist/development/src/type-schema/settings.cjs.map +0 -1
- package/dist/development/src/type-schema/settings.js +0 -17
- package/dist/development/src/type-schema/settings.js.map +0 -1
- package/dist/development/src/type-schema/validation.cjs +0 -115
- package/dist/development/src/type-schema/validation.cjs.map +0 -1
- package/dist/development/src/type-schema/validation.js +0 -98
- package/dist/development/src/type-schema/validation.js.map +0 -1
- package/dist/development/src/type-schema/where.cjs +0 -44
- package/dist/development/src/type-schema/where.cjs.map +0 -1
- package/dist/development/src/type-schema/where.js +0 -27
- package/dist/development/src/type-schema/where.js.map +0 -1
- package/dist/development/src/utils/assertNever.cjs +0 -7
- package/dist/development/src/utils/assertNever.cjs.map +0 -1
- package/dist/development/src/utils/assertNever.js +0 -7
- package/dist/development/src/utils/assertNever.js.map +0 -1
- package/dist/development/src/utils/deepCompare.cjs +0 -134
- package/dist/development/src/utils/deepCompare.cjs.map +0 -1
- package/dist/development/src/utils/deepCompare.js +0 -134
- package/dist/development/src/utils/deepCompare.js.map +0 -1
- package/dist/development/src/utils/isIt.cjs +0 -7
- package/dist/development/src/utils/isIt.cjs.map +0 -1
- package/dist/development/src/utils/isIt.js +0 -7
- package/dist/development/src/utils/isIt.js.map +0 -1
- package/dist/development/src/utils/printJsValue.cjs +0 -42
- package/dist/development/src/utils/printJsValue.cjs.map +0 -1
- package/dist/development/src/utils/printJsValue.js +0 -42
- package/dist/development/src/utils/printJsValue.js.map +0 -1
- package/dist/development/src/validation/AclValidator.cjs +0 -168
- package/dist/development/src/validation/AclValidator.cjs.map +0 -1
- package/dist/development/src/validation/AclValidator.js +0 -168
- package/dist/development/src/validation/AclValidator.js.map +0 -1
- package/dist/development/src/validation/ActionsValidator.cjs +0 -127
- package/dist/development/src/validation/ActionsValidator.cjs.map +0 -1
- package/dist/development/src/validation/ActionsValidator.js +0 -110
- package/dist/development/src/validation/ActionsValidator.js.map +0 -1
- package/dist/development/src/validation/MembershipResolver.cjs +0 -129
- package/dist/development/src/validation/MembershipResolver.cjs.map +0 -1
- package/dist/development/src/validation/MembershipResolver.js +0 -129
- package/dist/development/src/validation/MembershipResolver.js.map +0 -1
- package/dist/development/src/validation/ModelValidator.cjs +0 -310
- package/dist/development/src/validation/ModelValidator.cjs.map +0 -1
- package/dist/development/src/validation/ModelValidator.js +0 -310
- package/dist/development/src/validation/ModelValidator.js.map +0 -1
- package/dist/development/src/validation/SchemaValidator.cjs +0 -29
- package/dist/development/src/validation/SchemaValidator.cjs.map +0 -1
- package/dist/development/src/validation/SchemaValidator.js +0 -29
- package/dist/development/src/validation/SchemaValidator.js.map +0 -1
- package/dist/development/src/validation/ValidationValidator.cjs +0 -121
- package/dist/development/src/validation/ValidationValidator.cjs.map +0 -1
- package/dist/development/src/validation/ValidationValidator.js +0 -121
- package/dist/development/src/validation/ValidationValidator.js.map +0 -1
- package/dist/development/src/validation/errors.cjs +0 -16
- package/dist/development/src/validation/errors.cjs.map +0 -1
- package/dist/development/src/validation/errors.js +0 -16
- package/dist/development/src/validation/errors.js.map +0 -1
- package/dist/production/index.cjs +0 -110
- package/dist/production/index.cjs.map +0 -1
- package/dist/production/index.js +0 -94
- package/dist/production/index.js.map +0 -1
- package/dist/production/src/acl/AllowAllPermissionFactory.cjs +0 -42
- package/dist/production/src/acl/AllowAllPermissionFactory.cjs.map +0 -1
- package/dist/production/src/acl/AllowAllPermissionFactory.js +0 -42
- package/dist/production/src/acl/AllowAllPermissionFactory.js.map +0 -1
- package/dist/production/src/acl/PredicateDefinitionProcessor.cjs +0 -71
- package/dist/production/src/acl/PredicateDefinitionProcessor.cjs.map +0 -1
- package/dist/production/src/acl/PredicateDefinitionProcessor.js +0 -71
- package/dist/production/src/acl/PredicateDefinitionProcessor.js.map +0 -1
- package/dist/production/src/acl/schemaUtils.cjs +0 -11
- package/dist/production/src/acl/schemaUtils.cjs.map +0 -1
- package/dist/production/src/acl/schemaUtils.js +0 -11
- package/dist/production/src/acl/schemaUtils.js.map +0 -1
- package/dist/production/src/dataUtils.cjs +0 -59
- package/dist/production/src/dataUtils.cjs.map +0 -1
- package/dist/production/src/dataUtils.js +0 -59
- package/dist/production/src/dataUtils.js.map +0 -1
- package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.cjs +0 -117
- package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.cjs.map +0 -1
- package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.js +0 -117
- package/dist/production/src/definition-generator/AclDefinitionCodeGenerator.js.map +0 -1
- package/dist/production/src/definition-generator/DefinitionCodeGenerator.cjs +0 -218
- package/dist/production/src/definition-generator/DefinitionCodeGenerator.cjs.map +0 -1
- package/dist/production/src/definition-generator/DefinitionCodeGenerator.js +0 -218
- package/dist/production/src/definition-generator/DefinitionCodeGenerator.js.map +0 -1
- package/dist/production/src/definition-generator/DefinitionNamingConventions.cjs +0 -19
- package/dist/production/src/definition-generator/DefinitionNamingConventions.cjs.map +0 -1
- package/dist/production/src/definition-generator/DefinitionNamingConventions.js +0 -19
- package/dist/production/src/definition-generator/DefinitionNamingConventions.js.map +0 -1
- package/dist/production/src/definition-generator/TsDefinitionGenerator.cjs +0 -17
- package/dist/production/src/definition-generator/TsDefinitionGenerator.cjs.map +0 -1
- package/dist/production/src/definition-generator/TsDefinitionGenerator.js +0 -17
- package/dist/production/src/definition-generator/TsDefinitionGenerator.js.map +0 -1
- package/dist/production/src/lax/LaxSchemaConverter.cjs +0 -202
- package/dist/production/src/lax/LaxSchemaConverter.cjs.map +0 -1
- package/dist/production/src/lax/LaxSchemaConverter.js +0 -202
- package/dist/production/src/lax/LaxSchemaConverter.js.map +0 -1
- package/dist/production/src/lax/schema.cjs +0 -70
- package/dist/production/src/lax/schema.cjs.map +0 -1
- package/dist/production/src/lax/schema.js +0 -53
- package/dist/production/src/lax/schema.js.map +0 -1
- package/dist/production/src/model/NamingConventions.cjs +0 -28
- package/dist/production/src/model/NamingConventions.cjs.map +0 -1
- package/dist/production/src/model/NamingConventions.js +0 -28
- package/dist/production/src/model/NamingConventions.js.map +0 -1
- package/dist/production/src/model/modelUtils.cjs +0 -231
- package/dist/production/src/model/modelUtils.cjs.map +0 -1
- package/dist/production/src/model/modelUtils.js +0 -231
- package/dist/production/src/model/modelUtils.js.map +0 -1
- package/dist/production/src/model/resolveDefaultColumnType.cjs +0 -30
- package/dist/production/src/model/resolveDefaultColumnType.cjs.map +0 -1
- package/dist/production/src/model/resolveDefaultColumnType.js +0 -30
- package/dist/production/src/model/resolveDefaultColumnType.js.map +0 -1
- package/dist/production/src/schemaChecksum.cjs +0 -9
- package/dist/production/src/schemaChecksum.cjs.map +0 -1
- package/dist/production/src/schemaChecksum.js +0 -9
- package/dist/production/src/schemaChecksum.js.map +0 -1
- package/dist/production/src/schemaFilter.cjs +0 -24
- package/dist/production/src/schemaFilter.cjs.map +0 -1
- package/dist/production/src/schemaFilter.js +0 -24
- package/dist/production/src/schemaFilter.js.map +0 -1
- package/dist/production/src/schemaNormalizer.cjs +0 -72
- package/dist/production/src/schemaNormalizer.cjs.map +0 -1
- package/dist/production/src/schemaNormalizer.js +0 -72
- package/dist/production/src/schemaNormalizer.js.map +0 -1
- package/dist/production/src/type-schema/acl.cjs +0 -146
- package/dist/production/src/type-schema/acl.cjs.map +0 -1
- package/dist/production/src/type-schema/acl.js +0 -129
- package/dist/production/src/type-schema/acl.js.map +0 -1
- package/dist/production/src/type-schema/actions.cjs +0 -88
- package/dist/production/src/type-schema/actions.cjs.map +0 -1
- package/dist/production/src/type-schema/actions.js +0 -71
- package/dist/production/src/type-schema/actions.js.map +0 -1
- package/dist/production/src/type-schema/condition.cjs +0 -92
- package/dist/production/src/type-schema/condition.cjs.map +0 -1
- package/dist/production/src/type-schema/condition.js +0 -75
- package/dist/production/src/type-schema/condition.js.map +0 -1
- package/dist/production/src/type-schema/model.cjs +0 -219
- package/dist/production/src/type-schema/model.cjs.map +0 -1
- package/dist/production/src/type-schema/model.js +0 -203
- package/dist/production/src/type-schema/model.js.map +0 -1
- package/dist/production/src/type-schema/settings.cjs +0 -34
- package/dist/production/src/type-schema/settings.cjs.map +0 -1
- package/dist/production/src/type-schema/settings.js +0 -17
- package/dist/production/src/type-schema/settings.js.map +0 -1
- package/dist/production/src/type-schema/validation.cjs +0 -115
- package/dist/production/src/type-schema/validation.cjs.map +0 -1
- package/dist/production/src/type-schema/validation.js +0 -98
- package/dist/production/src/type-schema/validation.js.map +0 -1
- package/dist/production/src/type-schema/where.cjs +0 -44
- package/dist/production/src/type-schema/where.cjs.map +0 -1
- package/dist/production/src/type-schema/where.js +0 -27
- package/dist/production/src/type-schema/where.js.map +0 -1
- package/dist/production/src/utils/assertNever.cjs +0 -7
- package/dist/production/src/utils/assertNever.cjs.map +0 -1
- package/dist/production/src/utils/assertNever.js +0 -7
- package/dist/production/src/utils/assertNever.js.map +0 -1
- package/dist/production/src/utils/deepCompare.cjs +0 -134
- package/dist/production/src/utils/deepCompare.cjs.map +0 -1
- package/dist/production/src/utils/deepCompare.js +0 -134
- package/dist/production/src/utils/deepCompare.js.map +0 -1
- package/dist/production/src/utils/isIt.cjs +0 -7
- package/dist/production/src/utils/isIt.cjs.map +0 -1
- package/dist/production/src/utils/isIt.js +0 -7
- package/dist/production/src/utils/isIt.js.map +0 -1
- package/dist/production/src/utils/printJsValue.cjs +0 -42
- package/dist/production/src/utils/printJsValue.cjs.map +0 -1
- package/dist/production/src/utils/printJsValue.js +0 -42
- package/dist/production/src/utils/printJsValue.js.map +0 -1
- package/dist/production/src/validation/AclValidator.cjs +0 -168
- package/dist/production/src/validation/AclValidator.cjs.map +0 -1
- package/dist/production/src/validation/AclValidator.js +0 -168
- package/dist/production/src/validation/AclValidator.js.map +0 -1
- package/dist/production/src/validation/ActionsValidator.cjs +0 -127
- package/dist/production/src/validation/ActionsValidator.cjs.map +0 -1
- package/dist/production/src/validation/ActionsValidator.js +0 -110
- package/dist/production/src/validation/ActionsValidator.js.map +0 -1
- package/dist/production/src/validation/MembershipResolver.cjs +0 -129
- package/dist/production/src/validation/MembershipResolver.cjs.map +0 -1
- package/dist/production/src/validation/MembershipResolver.js +0 -129
- package/dist/production/src/validation/MembershipResolver.js.map +0 -1
- package/dist/production/src/validation/ModelValidator.cjs +0 -310
- package/dist/production/src/validation/ModelValidator.cjs.map +0 -1
- package/dist/production/src/validation/ModelValidator.js +0 -310
- package/dist/production/src/validation/ModelValidator.js.map +0 -1
- package/dist/production/src/validation/SchemaValidator.cjs +0 -29
- package/dist/production/src/validation/SchemaValidator.cjs.map +0 -1
- package/dist/production/src/validation/SchemaValidator.js +0 -29
- package/dist/production/src/validation/SchemaValidator.js.map +0 -1
- package/dist/production/src/validation/ValidationValidator.cjs +0 -121
- package/dist/production/src/validation/ValidationValidator.cjs.map +0 -1
- package/dist/production/src/validation/ValidationValidator.js +0 -121
- package/dist/production/src/validation/ValidationValidator.js.map +0 -1
- package/dist/production/src/validation/errors.cjs +0 -16
- package/dist/production/src/validation/errors.cjs.map +0 -1
- package/dist/production/src/validation/errors.js +0 -16
- package/dist/production/src/validation/errors.js.map +0 -1
- package/dist/tests/cases/unit/conditionSchema.test.d.ts +0 -2
- package/dist/tests/cases/unit/conditionSchema.test.d.ts.map +0 -1
- package/dist/tests/cases/unit/deepCompare.test.d.ts +0 -2
- package/dist/tests/cases/unit/deepCompare.test.d.ts.map +0 -1
- package/dist/tests/cases/unit/laxSchemaConverter.test.d.ts +0 -2
- package/dist/tests/cases/unit/laxSchemaConverter.test.d.ts.map +0 -1
- package/dist/tests/cases/unit/membershipResolver.test.d.ts +0 -2
- package/dist/tests/cases/unit/membershipResolver.test.d.ts.map +0 -1
- package/dist/tests/cases/unit/modelSchema.test.d.ts +0 -2
- package/dist/tests/cases/unit/modelSchema.test.d.ts.map +0 -1
- package/dist/tests/cases/unit/modelValidator.test.d.ts +0 -2
- package/dist/tests/cases/unit/modelValidator.test.d.ts.map +0 -1
- package/dist/tests/cases/unit/printJsvalue.test.d.ts +0 -2
- package/dist/tests/cases/unit/printJsvalue.test.d.ts.map +0 -1
- package/dist/tests/cases/unit/schemas/acl.d.ts +0 -12
- package/dist/tests/cases/unit/schemas/acl.d.ts.map +0 -1
- package/dist/tests/cases/unit/schemas/basic.d.ts +0 -4
- package/dist/tests/cases/unit/schemas/basic.d.ts.map +0 -1
- package/dist/tests/cases/unit/schemas/complex.d.ts +0 -12
- package/dist/tests/cases/unit/schemas/complex.d.ts.map +0 -1
- package/dist/tests/cases/unit/schemas/enum.d.ts +0 -6
- package/dist/tests/cases/unit/schemas/enum.d.ts.map +0 -1
- package/dist/tests/cases/unit/schemas/relations.d.ts +0 -14
- package/dist/tests/cases/unit/schemas/relations.d.ts.map +0 -1
- package/dist/tests/cases/unit/schemas/unique.d.ts +0 -4
- package/dist/tests/cases/unit/schemas/unique.d.ts.map +0 -1
- package/dist/tests/cases/unit/schemas/view.d.ts +0 -4
- package/dist/tests/cases/unit/schemas/view.d.ts.map +0 -1
- package/dist/tests/cases/unit/tsDefinitionGenerator.test.d.ts +0 -2
- package/dist/tests/cases/unit/tsDefinitionGenerator.test.d.ts.map +0 -1
- package/dist/tests/cases/unit/whereSchema.test.d.ts +0 -2
- package/dist/tests/cases/unit/whereSchema.test.d.ts.map +0 -1
- package/dist/tests/tsconfig.tsbuildinfo +0 -1
- package/dist/types/acl/AllowAllPermissionFactory.d.ts +0 -7
- package/dist/types/acl/AllowAllPermissionFactory.d.ts.map +0 -1
- package/dist/types/acl/PredicateDefinitionProcessor.d.ts +0 -32
- package/dist/types/acl/PredicateDefinitionProcessor.d.ts.map +0 -1
- package/dist/types/acl/index.d.ts +0 -4
- package/dist/types/acl/index.d.ts.map +0 -1
- package/dist/types/acl/schemaUtils.d.ts +0 -3
- package/dist/types/acl/schemaUtils.d.ts.map +0 -1
- package/dist/types/dataUtils.d.ts +0 -18
- package/dist/types/dataUtils.d.ts.map +0 -1
- package/dist/types/definition-generator/AclDefinitionCodeGenerator.d.ts +0 -19
- package/dist/types/definition-generator/AclDefinitionCodeGenerator.d.ts.map +0 -1
- package/dist/types/definition-generator/DefinitionCodeGenerator.d.ts +0 -27
- package/dist/types/definition-generator/DefinitionCodeGenerator.d.ts.map +0 -1
- package/dist/types/definition-generator/DefinitionNamingConventions.d.ts +0 -7
- package/dist/types/definition-generator/DefinitionNamingConventions.d.ts.map +0 -1
- package/dist/types/definition-generator/TsDefinitionGenerator.d.ts +0 -12
- package/dist/types/definition-generator/TsDefinitionGenerator.d.ts.map +0 -1
- package/dist/types/definition-generator/index.d.ts +0 -5
- package/dist/types/definition-generator/index.d.ts.map +0 -1
- package/dist/types/index.d.ts +0 -15
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/lax/LaxSchemaConverter.d.ts +0 -10
- package/dist/types/lax/LaxSchemaConverter.d.ts.map +0 -1
- package/dist/types/lax/index.d.ts +0 -3
- package/dist/types/lax/index.d.ts.map +0 -1
- package/dist/types/lax/schema.d.ts +0 -285
- package/dist/types/lax/schema.d.ts.map +0 -1
- package/dist/types/model/NamingConventions.d.ts +0 -17
- package/dist/types/model/NamingConventions.d.ts.map +0 -1
- package/dist/types/model/index.d.ts +0 -4
- package/dist/types/model/index.d.ts.map +0 -1
- package/dist/types/model/modelUtils.d.ts +0 -28
- package/dist/types/model/modelUtils.d.ts.map +0 -1
- package/dist/types/model/resolveDefaultColumnType.d.ts +0 -3
- package/dist/types/model/resolveDefaultColumnType.d.ts.map +0 -1
- package/dist/types/schemaChecksum.d.ts +0 -3
- package/dist/types/schemaChecksum.d.ts.map +0 -1
- package/dist/types/schemaFilter.d.ts +0 -3
- package/dist/types/schemaFilter.d.ts.map +0 -1
- package/dist/types/schemaNormalizer.d.ts +0 -3
- package/dist/types/schemaNormalizer.d.ts.map +0 -1
- package/dist/types/tsconfig.tsbuildinfo +0 -1
- package/dist/types/type-schema/acl.d.ts +0 -10
- package/dist/types/type-schema/acl.d.ts.map +0 -1
- package/dist/types/type-schema/actions.d.ts +0 -32
- package/dist/types/type-schema/actions.d.ts.map +0 -1
- package/dist/types/type-schema/condition.d.ts +0 -4
- package/dist/types/type-schema/condition.d.ts.map +0 -1
- package/dist/types/type-schema/index.d.ts +0 -6
- package/dist/types/type-schema/index.d.ts.map +0 -1
- package/dist/types/type-schema/model.d.ts +0 -30
- package/dist/types/type-schema/model.d.ts.map +0 -1
- package/dist/types/type-schema/settings.d.ts +0 -41
- package/dist/types/type-schema/settings.d.ts.map +0 -1
- package/dist/types/type-schema/validation.d.ts +0 -15
- package/dist/types/type-schema/validation.d.ts.map +0 -1
- package/dist/types/type-schema/where.d.ts +0 -7
- package/dist/types/type-schema/where.d.ts.map +0 -1
- package/dist/types/utils/assertNever.d.ts +0 -2
- package/dist/types/utils/assertNever.d.ts.map +0 -1
- package/dist/types/utils/deepCompare.d.ts +0 -13
- package/dist/types/utils/deepCompare.d.ts.map +0 -1
- package/dist/types/utils/index.d.ts +0 -4
- package/dist/types/utils/index.d.ts.map +0 -1
- package/dist/types/utils/isIt.d.ts +0 -2
- package/dist/types/utils/isIt.d.ts.map +0 -1
- package/dist/types/utils/printJsValue.d.ts +0 -13
- package/dist/types/utils/printJsValue.d.ts.map +0 -1
- package/dist/types/validation/AclValidator.d.ts +0 -20
- package/dist/types/validation/AclValidator.d.ts.map +0 -1
- package/dist/types/validation/ActionsValidator.d.ts +0 -13
- package/dist/types/validation/ActionsValidator.d.ts.map +0 -1
- package/dist/types/validation/MembershipResolver.d.ts +0 -37
- package/dist/types/validation/MembershipResolver.d.ts.map +0 -1
- package/dist/types/validation/ModelValidator.d.ts +0 -20
- package/dist/types/validation/ModelValidator.d.ts.map +0 -1
- package/dist/types/validation/SchemaValidator.d.ts +0 -11
- package/dist/types/validation/SchemaValidator.d.ts.map +0 -1
- package/dist/types/validation/ValidationValidator.d.ts +0 -14
- package/dist/types/validation/ValidationValidator.d.ts.map +0 -1
- package/dist/types/validation/errors.d.ts +0 -14
- package/dist/types/validation/errors.d.ts.map +0 -1
- package/dist/types/validation/index.d.ts +0 -7
- package/dist/types/validation/index.d.ts.map +0 -1
- package/tests/cases/unit/schemas/.eslintignore +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.cjs","sources":["../../../../../packages/schema-utils/src/type-schema/validation.ts"],"sourcesContent":["import * as Typesafe from '@contember/typesafe'\nimport { Validation } from '@contember/schema'\n\nconst messageSchema = Typesafe.intersection(\n\tTypesafe.object({\n\t\ttext: Typesafe.string,\n\t}),\n\tTypesafe.partial({\n\t\tparameters: Typesafe.array(Typesafe.union(Typesafe.string, Typesafe.number)),\n\t}),\n)\nconst literalArgumentFactory = <T extends Typesafe.Json>(inner: Typesafe.Type<T>) => Typesafe.object({\n\ttype: Typesafe.literal(Validation.ArgumentType.literal),\n\tvalue: inner,\n})\n\nconst validatorArgumentSchema = Typesafe.object({\n\ttype: Typesafe.literal(Validation.ArgumentType.validator),\n\tvalidator: (v, p): Validation.Validator => validatorSchema(v, p),\n})\nconst pathArgumentSchema = Typesafe.object({\n\ttype: Typesafe.literal(Validation.ArgumentType.path),\n\tpath: Typesafe.array(Typesafe.string),\n})\n\nconst validatorSchema = Typesafe.union(\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('and'),\n\t\targs: Typesafe.array(validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('or'),\n\t\targs: Typesafe.array(validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('conditional'),\n\t\targs: Typesafe.tuple(validatorArgumentSchema, validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('pattern'),\n\t\targs: Typesafe.tuple(literalArgumentFactory(Typesafe.tuple(Typesafe.string, Typesafe.string))),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('lengthRange'),\n\t\targs: Typesafe.tuple(\n\t\t\tliteralArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number)),\n\t\t\tliteralArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number)),\n\t\t),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('range'),\n\t\targs: Typesafe.tuple(\n\t\t\tliteralArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number)),\n\t\t\tliteralArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number)),\n\t\t),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('equals'),\n\t\targs: Typesafe.tuple(literalArgumentFactory(Typesafe.anyJson)),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('not'),\n\t\targs: Typesafe.tuple(validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('empty'),\n\t\targs: Typesafe.tuple(),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('defined'),\n\t\targs: Typesafe.tuple(),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('inContext'),\n\t\targs: Typesafe.tuple(pathArgumentSchema, validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('every'),\n\t\targs: Typesafe.tuple(validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('any'),\n\t\targs: Typesafe.tuple(validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('filter'),\n\t\targs: Typesafe.tuple(validatorArgumentSchema, validatorArgumentSchema),\n\t}),\n)\nconst validatorSchemaCheck: Typesafe.Equals<Validation.Validator, ReturnType<typeof validatorSchema>> = true\n\nconst validationRuleSchema = Typesafe.object({\n\tvalidator: validatorSchema as Typesafe.Type<Validation.Validator>,\n\tmessage: messageSchema,\n})\n\nexport const validationSchema = Typesafe.record(\n\tTypesafe.string,\n\tTypesafe.record(Typesafe.string, Typesafe.array(validationRuleSchema)),\n)\n"],"names":["Typesafe","Validation"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA,MAAM,gBAAgBA,oBAAS;AAAA,EAC9BA,oBAAS,OAAO;AAAA,IACf,MAAMA,oBAAS;AAAA,EAAA,CACf;AAAA,EACDA,oBAAS,QAAQ;AAAA,IAChB,YAAYA,oBAAS,MAAMA,oBAAS,MAAMA,oBAAS,QAAQA,oBAAS,MAAM,CAAC;AAAA,EAC3E,CAAA;AACF;AACA,MAAM,yBAAyB,CAA0B,UAA4BA,oBAAS,OAAO;AAAA,EACpG,MAAMA,oBAAS,QAAQC,OAAAA,WAAW,aAAa,OAAO;AAAA,EACtD,OAAO;AACR,CAAC;AAED,MAAM,0BAA0BD,oBAAS,OAAO;AAAA,EAC/C,MAAMA,oBAAS,QAAQC,OAAAA,WAAW,aAAa,SAAS;AAAA,EACxD,WAAW,CAAC,GAAG,MAA4B,gBAAgB,GAAG,CAAC;AAChE,CAAC;AACD,MAAM,qBAAqBD,oBAAS,OAAO;AAAA,EAC1C,MAAMA,oBAAS,QAAQC,OAAAA,WAAW,aAAa,IAAI;AAAA,EACnD,MAAMD,oBAAS,MAAMA,oBAAS,MAAM;AACrC,CAAC;AAED,MAAM,kBAAkBA,oBAAS;AAAA,EAChCA,oBAAS,OAAO;AAAA,IACf,WAAWA,oBAAS,QAAQ,KAAK;AAAA,IACjC,MAAMA,oBAAS,MAAM,uBAAuB;AAAA,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AAAA,EACDA,oBAAS,OAAO;AAAA,IACf,WAAWA,oBAAS,QAAQ,OAAO;AAAA,IACnC,MAAMA,oBAAS,MAAM;AAAA,EAAA,CACrB;AAAA,EACDA,oBAAS,OAAO;AAAA,IACf,WAAWA,oBAAS,QAAQ,SAAS;AAAA,IACrC,MAAMA,oBAAS,MAAM;AAAA,EAAA,CACrB;AAAA,EACDA,oBAAS,OAAO;AAAA,IACf,WAAWA,oBAAS,QAAQ,WAAW;AAAA,IACvC,MAAMA,oBAAS,MAAM,oBAAoB,uBAAuB;AAAA,EAAA,CAChE;AAAA,EACDA,oBAAS,OAAO;AAAA,IACf,WAAWA,oBAAS,QAAQ,OAAO;AAAA,IACnC,MAAMA,oBAAS,MAAM,uBAAuB;AAAA,EAAA,CAC5C;AAAA,EACDA,oBAAS,OAAO;AAAA,IACf,WAAWA,oBAAS,QAAQ,KAAK;AAAA,IACjC,MAAMA,oBAAS,MAAM,uBAAuB;AAAA,EAAA,CAC5C;AAAA,EACDA,oBAAS,OAAO;AAAA,IACf,WAAWA,oBAAS,QAAQ,QAAQ;AAAA,IACpC,MAAMA,oBAAS,MAAM,yBAAyB,uBAAuB;AAAA,EACrE,CAAA;AACF;AAGA,MAAM,uBAAuBA,oBAAS,OAAO;AAAA,EAC5C,WAAW;AAAA,EACX,SAAS;AACV,CAAC;AAEM,MAAM,mBAAmBA,oBAAS;AAAA,EACxCA,oBAAS;AAAA,EACTA,oBAAS,OAAOA,oBAAS,QAAQA,oBAAS,MAAM,oBAAoB,CAAC;AACtE;;"}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import * as Typesafe from "@contember/typesafe";
|
|
2
|
-
import { Validation } from "@contember/schema";
|
|
3
|
-
const messageSchema = Typesafe.intersection(
|
|
4
|
-
Typesafe.object({
|
|
5
|
-
text: Typesafe.string
|
|
6
|
-
}),
|
|
7
|
-
Typesafe.partial({
|
|
8
|
-
parameters: Typesafe.array(Typesafe.union(Typesafe.string, Typesafe.number))
|
|
9
|
-
})
|
|
10
|
-
);
|
|
11
|
-
const literalArgumentFactory = (inner) => Typesafe.object({
|
|
12
|
-
type: Typesafe.literal(Validation.ArgumentType.literal),
|
|
13
|
-
value: inner
|
|
14
|
-
});
|
|
15
|
-
const validatorArgumentSchema = Typesafe.object({
|
|
16
|
-
type: Typesafe.literal(Validation.ArgumentType.validator),
|
|
17
|
-
validator: (v, p) => validatorSchema(v, p)
|
|
18
|
-
});
|
|
19
|
-
const pathArgumentSchema = Typesafe.object({
|
|
20
|
-
type: Typesafe.literal(Validation.ArgumentType.path),
|
|
21
|
-
path: Typesafe.array(Typesafe.string)
|
|
22
|
-
});
|
|
23
|
-
const validatorSchema = Typesafe.union(
|
|
24
|
-
Typesafe.object({
|
|
25
|
-
operation: Typesafe.literal("and"),
|
|
26
|
-
args: Typesafe.array(validatorArgumentSchema)
|
|
27
|
-
}),
|
|
28
|
-
Typesafe.object({
|
|
29
|
-
operation: Typesafe.literal("or"),
|
|
30
|
-
args: Typesafe.array(validatorArgumentSchema)
|
|
31
|
-
}),
|
|
32
|
-
Typesafe.object({
|
|
33
|
-
operation: Typesafe.literal("conditional"),
|
|
34
|
-
args: Typesafe.tuple(validatorArgumentSchema, validatorArgumentSchema)
|
|
35
|
-
}),
|
|
36
|
-
Typesafe.object({
|
|
37
|
-
operation: Typesafe.literal("pattern"),
|
|
38
|
-
args: Typesafe.tuple(literalArgumentFactory(Typesafe.tuple(Typesafe.string, Typesafe.string)))
|
|
39
|
-
}),
|
|
40
|
-
Typesafe.object({
|
|
41
|
-
operation: Typesafe.literal("lengthRange"),
|
|
42
|
-
args: Typesafe.tuple(
|
|
43
|
-
literalArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number)),
|
|
44
|
-
literalArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number))
|
|
45
|
-
)
|
|
46
|
-
}),
|
|
47
|
-
Typesafe.object({
|
|
48
|
-
operation: Typesafe.literal("range"),
|
|
49
|
-
args: Typesafe.tuple(
|
|
50
|
-
literalArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number)),
|
|
51
|
-
literalArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number))
|
|
52
|
-
)
|
|
53
|
-
}),
|
|
54
|
-
Typesafe.object({
|
|
55
|
-
operation: Typesafe.literal("equals"),
|
|
56
|
-
args: Typesafe.tuple(literalArgumentFactory(Typesafe.anyJson))
|
|
57
|
-
}),
|
|
58
|
-
Typesafe.object({
|
|
59
|
-
operation: Typesafe.literal("not"),
|
|
60
|
-
args: Typesafe.tuple(validatorArgumentSchema)
|
|
61
|
-
}),
|
|
62
|
-
Typesafe.object({
|
|
63
|
-
operation: Typesafe.literal("empty"),
|
|
64
|
-
args: Typesafe.tuple()
|
|
65
|
-
}),
|
|
66
|
-
Typesafe.object({
|
|
67
|
-
operation: Typesafe.literal("defined"),
|
|
68
|
-
args: Typesafe.tuple()
|
|
69
|
-
}),
|
|
70
|
-
Typesafe.object({
|
|
71
|
-
operation: Typesafe.literal("inContext"),
|
|
72
|
-
args: Typesafe.tuple(pathArgumentSchema, validatorArgumentSchema)
|
|
73
|
-
}),
|
|
74
|
-
Typesafe.object({
|
|
75
|
-
operation: Typesafe.literal("every"),
|
|
76
|
-
args: Typesafe.tuple(validatorArgumentSchema)
|
|
77
|
-
}),
|
|
78
|
-
Typesafe.object({
|
|
79
|
-
operation: Typesafe.literal("any"),
|
|
80
|
-
args: Typesafe.tuple(validatorArgumentSchema)
|
|
81
|
-
}),
|
|
82
|
-
Typesafe.object({
|
|
83
|
-
operation: Typesafe.literal("filter"),
|
|
84
|
-
args: Typesafe.tuple(validatorArgumentSchema, validatorArgumentSchema)
|
|
85
|
-
})
|
|
86
|
-
);
|
|
87
|
-
const validationRuleSchema = Typesafe.object({
|
|
88
|
-
validator: validatorSchema,
|
|
89
|
-
message: messageSchema
|
|
90
|
-
});
|
|
91
|
-
const validationSchema = Typesafe.record(
|
|
92
|
-
Typesafe.string,
|
|
93
|
-
Typesafe.record(Typesafe.string, Typesafe.array(validationRuleSchema))
|
|
94
|
-
);
|
|
95
|
-
export {
|
|
96
|
-
validationSchema
|
|
97
|
-
};
|
|
98
|
-
//# sourceMappingURL=validation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sources":["../../../../../packages/schema-utils/src/type-schema/validation.ts"],"sourcesContent":["import * as Typesafe from '@contember/typesafe'\nimport { Validation } from '@contember/schema'\n\nconst messageSchema = Typesafe.intersection(\n\tTypesafe.object({\n\t\ttext: Typesafe.string,\n\t}),\n\tTypesafe.partial({\n\t\tparameters: Typesafe.array(Typesafe.union(Typesafe.string, Typesafe.number)),\n\t}),\n)\nconst literalArgumentFactory = <T extends Typesafe.Json>(inner: Typesafe.Type<T>) => Typesafe.object({\n\ttype: Typesafe.literal(Validation.ArgumentType.literal),\n\tvalue: inner,\n})\n\nconst validatorArgumentSchema = Typesafe.object({\n\ttype: Typesafe.literal(Validation.ArgumentType.validator),\n\tvalidator: (v, p): Validation.Validator => validatorSchema(v, p),\n})\nconst pathArgumentSchema = Typesafe.object({\n\ttype: Typesafe.literal(Validation.ArgumentType.path),\n\tpath: Typesafe.array(Typesafe.string),\n})\n\nconst validatorSchema = Typesafe.union(\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('and'),\n\t\targs: Typesafe.array(validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('or'),\n\t\targs: Typesafe.array(validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('conditional'),\n\t\targs: Typesafe.tuple(validatorArgumentSchema, validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('pattern'),\n\t\targs: Typesafe.tuple(literalArgumentFactory(Typesafe.tuple(Typesafe.string, Typesafe.string))),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('lengthRange'),\n\t\targs: Typesafe.tuple(\n\t\t\tliteralArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number)),\n\t\t\tliteralArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number)),\n\t\t),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('range'),\n\t\targs: Typesafe.tuple(\n\t\t\tliteralArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number)),\n\t\t\tliteralArgumentFactory(Typesafe.union(Typesafe.null_, Typesafe.number)),\n\t\t),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('equals'),\n\t\targs: Typesafe.tuple(literalArgumentFactory(Typesafe.anyJson)),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('not'),\n\t\targs: Typesafe.tuple(validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('empty'),\n\t\targs: Typesafe.tuple(),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('defined'),\n\t\targs: Typesafe.tuple(),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('inContext'),\n\t\targs: Typesafe.tuple(pathArgumentSchema, validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('every'),\n\t\targs: Typesafe.tuple(validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('any'),\n\t\targs: Typesafe.tuple(validatorArgumentSchema),\n\t}),\n\tTypesafe.object({\n\t\toperation: Typesafe.literal('filter'),\n\t\targs: Typesafe.tuple(validatorArgumentSchema, validatorArgumentSchema),\n\t}),\n)\nconst validatorSchemaCheck: Typesafe.Equals<Validation.Validator, ReturnType<typeof validatorSchema>> = true\n\nconst validationRuleSchema = Typesafe.object({\n\tvalidator: validatorSchema as Typesafe.Type<Validation.Validator>,\n\tmessage: messageSchema,\n})\n\nexport const validationSchema = Typesafe.record(\n\tTypesafe.string,\n\tTypesafe.record(Typesafe.string, Typesafe.array(validationRuleSchema)),\n)\n"],"names":[],"mappings":";;AAGA,MAAM,g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ACD,SAAS,OAAO;AAAA,IACf,WAAW,SAAS,QAAQ,QAAQ;AAAA,IACpC,MAAM,SAAS,MAAM,yBAAyB,uBAAuB;AAAA,EACrE,CAAA;AACF;AAGA,MAAM,uBAAuB,SAAS,OAAO;AAAA,EAC5C,WAAW;AAAA,EACX,SAAS;AACV,CAAC;AAEM,MAAM,mBAAmB,SAAS;AAAA,EACxC,SAAS;AAAA,EACT,SAAS,OAAO,SAAS,QAAQ,SAAS,MAAM,oBAAoB,CAAC;AACtE;"}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const modelUtils = require("../model/modelUtils.cjs");
|
|
4
|
-
require("@contember/schema");
|
|
5
|
-
const condition = require("./condition.cjs");
|
|
6
|
-
const Typesafe = require("@contember/typesafe");
|
|
7
|
-
function _interopNamespaceDefault(e) {
|
|
8
|
-
const n = Object.create(null, { [Symbol.toStringTag]: { value: "Module" } });
|
|
9
|
-
if (e) {
|
|
10
|
-
for (const k in e) {
|
|
11
|
-
if (k !== "default") {
|
|
12
|
-
const d = Object.getOwnPropertyDescriptor(e, k);
|
|
13
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: () => e[k]
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
n.default = e;
|
|
21
|
-
return Object.freeze(n);
|
|
22
|
-
}
|
|
23
|
-
const Typesafe__namespace = /* @__PURE__ */ _interopNamespaceDefault(Typesafe);
|
|
24
|
-
const whereSchema = ({ schema, entity }) => {
|
|
25
|
-
return (input, path = []) => {
|
|
26
|
-
const whereSchemaInner = Typesafe__namespace.noExtraProps(Typesafe__namespace.partial({
|
|
27
|
-
and: Typesafe__namespace.array(whereSchema({ schema, entity })),
|
|
28
|
-
or: Typesafe__namespace.array(whereSchema({ schema, entity })),
|
|
29
|
-
not: whereSchema({ schema, entity }),
|
|
30
|
-
...Object.fromEntries(Object.values(entity.fields).map((it) => {
|
|
31
|
-
return [
|
|
32
|
-
it.name,
|
|
33
|
-
modelUtils.acceptFieldVisitor(schema, entity, it.name, {
|
|
34
|
-
visitColumn: ({ column }) => condition.conditionSchema(column.type),
|
|
35
|
-
visitRelation: ({ targetEntity }) => whereSchema({ schema, entity: targetEntity })
|
|
36
|
-
})
|
|
37
|
-
];
|
|
38
|
-
}))
|
|
39
|
-
}));
|
|
40
|
-
return whereSchemaInner(input, path);
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
exports.whereSchema = whereSchema;
|
|
44
|
-
//# sourceMappingURL=where.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"where.cjs","sources":["../../../../../packages/schema-utils/src/type-schema/where.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { acceptFieldVisitor } from '../model'\nimport { conditionSchema } from './condition'\nimport * as Typesafe from '@contember/typesafe'\n\nexport const whereSchema = ({ schema, entity }: {\n\tschema: Model.Schema\n\tentity: Model.Entity\n}): Typesafe.Type<Input.Where> => {\n\treturn (input: unknown, path: PropertyKey[] = []): Input.Where => {\n\t\tconst whereSchemaInner = Typesafe.noExtraProps(Typesafe.partial({\n\t\t\tand: Typesafe.array(whereSchema({ schema, entity })),\n\t\t\tor: Typesafe.array(whereSchema({ schema, entity })),\n\t\t\tnot: whereSchema({ schema, entity }),\n\t\t\t...Object.fromEntries(Object.values(entity.fields).map((it): [string, Typesafe.Type<Input.Where[any]>] => {\n\t\t\t\treturn [\n\t\t\t\t\tit.name,\n\t\t\t\t\tacceptFieldVisitor(schema, entity, it.name, {\n\t\t\t\t\t\tvisitColumn: ({ column }) => conditionSchema(column.type),\n\t\t\t\t\t\tvisitRelation: ({ targetEntity }) => whereSchema({ schema, entity: targetEntity }),\n\t\t\t\t\t}),\n\t\t\t\t]\n\t\t\t})),\n\t\t}))\n\n\t\treturn whereSchemaInner(input, path)\n\t}\n}\n"],"names":["Typesafe","acceptFieldVisitor","conditionSchema"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAKO,MAAM,cAAc,CAAC,EAAE,QAAQ,aAGJ;AACjC,SAAO,CAAC,OAAgB,OAAsB,OAAoB;AACjE,UAAM,mBAAmBA,oBAAS,aAAaA,oBAAS,QAAQ;AAAA,MAC/D,KAAKA,oBAAS,MAAM,YAAY,EAAE,QAAQ,OAAA,CAAQ,CAAC;AAAA,MACnD,IAAIA,oBAAS,MAAM,YAAY,EAAE,QAAQ,OAAA,CAAQ,CAAC;AAAA,MAClD,KAAK,YAAY,EAAE,QAAQ,QAAQ;AAAA,MACnC,GAAG,OAAO,YAAY,OAAO,OAAO,OAAO,MAAM,EAAE,IAAI,CAAC,OAAkD;AAClG,eAAA;AAAA,UACN,GAAG;AAAA,UACHC,WAAAA,mBAAmB,QAAQ,QAAQ,GAAG,MAAM;AAAA,YAC3C,aAAa,CAAC,EAAE,aAAaC,UAAAA,gBAAgB,OAAO,IAAI;AAAA,YACxD,eAAe,CAAC,EAAE,aAAa,MAAM,YAAY,EAAE,QAAQ,QAAQ,aAAc,CAAA;AAAA,UACjF,CAAA;AAAA,QACF;AAAA,MAAA,CACA,CAAC;AAAA,IAAA,CACF,CAAC;AAEK,WAAA,iBAAiB,OAAO,IAAI;AAAA,EACpC;AACD;;"}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { acceptFieldVisitor } from "../model/modelUtils.js";
|
|
2
|
-
import "@contember/schema";
|
|
3
|
-
import { conditionSchema } from "./condition.js";
|
|
4
|
-
import * as Typesafe from "@contember/typesafe";
|
|
5
|
-
const whereSchema = ({ schema, entity }) => {
|
|
6
|
-
return (input, path = []) => {
|
|
7
|
-
const whereSchemaInner = Typesafe.noExtraProps(Typesafe.partial({
|
|
8
|
-
and: Typesafe.array(whereSchema({ schema, entity })),
|
|
9
|
-
or: Typesafe.array(whereSchema({ schema, entity })),
|
|
10
|
-
not: whereSchema({ schema, entity }),
|
|
11
|
-
...Object.fromEntries(Object.values(entity.fields).map((it) => {
|
|
12
|
-
return [
|
|
13
|
-
it.name,
|
|
14
|
-
acceptFieldVisitor(schema, entity, it.name, {
|
|
15
|
-
visitColumn: ({ column }) => conditionSchema(column.type),
|
|
16
|
-
visitRelation: ({ targetEntity }) => whereSchema({ schema, entity: targetEntity })
|
|
17
|
-
})
|
|
18
|
-
];
|
|
19
|
-
}))
|
|
20
|
-
}));
|
|
21
|
-
return whereSchemaInner(input, path);
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
whereSchema
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=where.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"where.js","sources":["../../../../../packages/schema-utils/src/type-schema/where.ts"],"sourcesContent":["import { Input, Model } from '@contember/schema'\nimport { acceptFieldVisitor } from '../model'\nimport { conditionSchema } from './condition'\nimport * as Typesafe from '@contember/typesafe'\n\nexport const whereSchema = ({ schema, entity }: {\n\tschema: Model.Schema\n\tentity: Model.Entity\n}): Typesafe.Type<Input.Where> => {\n\treturn (input: unknown, path: PropertyKey[] = []): Input.Where => {\n\t\tconst whereSchemaInner = Typesafe.noExtraProps(Typesafe.partial({\n\t\t\tand: Typesafe.array(whereSchema({ schema, entity })),\n\t\t\tor: Typesafe.array(whereSchema({ schema, entity })),\n\t\t\tnot: whereSchema({ schema, entity }),\n\t\t\t...Object.fromEntries(Object.values(entity.fields).map((it): [string, Typesafe.Type<Input.Where[any]>] => {\n\t\t\t\treturn [\n\t\t\t\t\tit.name,\n\t\t\t\t\tacceptFieldVisitor(schema, entity, it.name, {\n\t\t\t\t\t\tvisitColumn: ({ column }) => conditionSchema(column.type),\n\t\t\t\t\t\tvisitRelation: ({ targetEntity }) => whereSchema({ schema, entity: targetEntity }),\n\t\t\t\t\t}),\n\t\t\t\t]\n\t\t\t})),\n\t\t}))\n\n\t\treturn whereSchemaInner(input, path)\n\t}\n}\n"],"names":[],"mappings":";;;;AAKO,MAAM,cAAc,CAAC,EAAE,QAAQ,aAGJ;AACjC,SAAO,CAAC,OAAgB,OAAsB,OAAoB;AACjE,UAAM,mBAAmB,SAAS,aAAa,SAAS,QAAQ;AAAA,MAC/D,KAAK,SAAS,MAAM,YAAY,EAAE,QAAQ,OAAA,CAAQ,CAAC;AAAA,MACnD,IAAI,SAAS,MAAM,YAAY,EAAE,QAAQ,OAAA,CAAQ,CAAC;AAAA,MAClD,KAAK,YAAY,EAAE,QAAQ,QAAQ;AAAA,MACnC,GAAG,OAAO,YAAY,OAAO,OAAO,OAAO,MAAM,EAAE,IAAI,CAAC,OAAkD;AAClG,eAAA;AAAA,UACN,GAAG;AAAA,UACH,mBAAmB,QAAQ,QAAQ,GAAG,MAAM;AAAA,YAC3C,aAAa,CAAC,EAAE,aAAa,gBAAgB,OAAO,IAAI;AAAA,YACxD,eAAe,CAAC,EAAE,aAAa,MAAM,YAAY,EAAE,QAAQ,QAAQ,aAAc,CAAA;AAAA,UACjF,CAAA;AAAA,QACF;AAAA,MAAA,CACA,CAAC;AAAA,IAAA,CACF,CAAC;AAEK,WAAA,iBAAiB,OAAO,IAAI;AAAA,EACpC;AACD;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assertNever.cjs","sources":["../../../../../packages/schema-utils/src/utils/assertNever.ts"],"sourcesContent":["export function assertNever(_: never): never {\n\tthrow new Error()\n}\n"],"names":[],"mappings":";;AAAO,SAAS,YAAY,GAAiB;AAC5C,QAAM,IAAI,MAAM;AACjB;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"assertNever.js","sources":["../../../../../packages/schema-utils/src/utils/assertNever.ts"],"sourcesContent":["export function assertNever(_: never): never {\n\tthrow new Error()\n}\n"],"names":[],"mappings":"AAAO,SAAS,YAAY,GAAiB;AAC5C,QAAM,IAAI,MAAM;AACjB;"}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const getType = (val) => {
|
|
4
|
-
if (val === null) {
|
|
5
|
-
return "null";
|
|
6
|
-
}
|
|
7
|
-
const type = typeof val;
|
|
8
|
-
if (type !== "object") {
|
|
9
|
-
return type;
|
|
10
|
-
}
|
|
11
|
-
if (Array.isArray(val)) {
|
|
12
|
-
return "array";
|
|
13
|
-
}
|
|
14
|
-
if (val instanceof Date) {
|
|
15
|
-
return "date";
|
|
16
|
-
}
|
|
17
|
-
if (val instanceof RegExp) {
|
|
18
|
-
return "regexp";
|
|
19
|
-
}
|
|
20
|
-
return "object";
|
|
21
|
-
};
|
|
22
|
-
const compareArraysIgnoreOrder = (a, b, path) => {
|
|
23
|
-
if (!Array.isArray(a) || !Array.isArray(b)) {
|
|
24
|
-
return [{ path, message: "Invalid type, expected array" }];
|
|
25
|
-
}
|
|
26
|
-
if (a.length !== b.length) {
|
|
27
|
-
return [{ path, message: `Array length: ${a.length} != ${b.length}` }];
|
|
28
|
-
}
|
|
29
|
-
const haystack = [...b];
|
|
30
|
-
for (const needle of a) {
|
|
31
|
-
const index = haystack.findIndex((it) => {
|
|
32
|
-
const errors = deepCompare(needle, it, path);
|
|
33
|
-
return errors.length === 0;
|
|
34
|
-
});
|
|
35
|
-
if (index < 0) {
|
|
36
|
-
return [{ path, message: `Array item: ${JSON.stringify(needle)} not found in ${JSON.stringify(haystack)}` }];
|
|
37
|
-
}
|
|
38
|
-
haystack.splice(index, 1);
|
|
39
|
-
}
|
|
40
|
-
if (haystack.length > 0) {
|
|
41
|
-
return [{ path, message: `Array items: ${JSON.stringify(haystack)} not found in ${JSON.stringify(a)}` }];
|
|
42
|
-
}
|
|
43
|
-
return [];
|
|
44
|
-
};
|
|
45
|
-
function deepCompare(a, b, path = [], getCustomComparator) {
|
|
46
|
-
if (a === b) {
|
|
47
|
-
return [];
|
|
48
|
-
}
|
|
49
|
-
const comparator = getCustomComparator?.(path);
|
|
50
|
-
if (comparator) {
|
|
51
|
-
return comparator(a, b);
|
|
52
|
-
}
|
|
53
|
-
const aType = getType(a);
|
|
54
|
-
const bType = getType(b);
|
|
55
|
-
if (aType !== bType) {
|
|
56
|
-
return [
|
|
57
|
-
{
|
|
58
|
-
path,
|
|
59
|
-
message: `Type: ${aType} != ${bType}`
|
|
60
|
-
}
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
|
-
if (aType === "array") {
|
|
64
|
-
const aLength = a.length;
|
|
65
|
-
const bLength = b.length;
|
|
66
|
-
if (aLength !== bLength) {
|
|
67
|
-
return [
|
|
68
|
-
{
|
|
69
|
-
path,
|
|
70
|
-
message: `Array length: ${aLength} != ${bLength}`
|
|
71
|
-
}
|
|
72
|
-
];
|
|
73
|
-
}
|
|
74
|
-
const errors = [];
|
|
75
|
-
for (let i = 0; i < aLength; i++) {
|
|
76
|
-
errors.push(...deepCompare(a[i], b[i], [...path, i], getCustomComparator));
|
|
77
|
-
}
|
|
78
|
-
return errors;
|
|
79
|
-
}
|
|
80
|
-
if (aType === "date") {
|
|
81
|
-
const aTime = a.getTime();
|
|
82
|
-
const bTime = b.getTime();
|
|
83
|
-
if (aTime == bTime) {
|
|
84
|
-
return [];
|
|
85
|
-
}
|
|
86
|
-
return [
|
|
87
|
-
{
|
|
88
|
-
path,
|
|
89
|
-
message: `Time: ${aTime} !== ${bTime}`
|
|
90
|
-
}
|
|
91
|
-
];
|
|
92
|
-
}
|
|
93
|
-
if (aType === "regexp") {
|
|
94
|
-
const aRegexp = a.toString();
|
|
95
|
-
const bRegexp = b.toString();
|
|
96
|
-
if (aRegexp === bRegexp) {
|
|
97
|
-
return [];
|
|
98
|
-
}
|
|
99
|
-
return [{ path, message: `Regexp: ${aRegexp} !== ${bRegexp}` }];
|
|
100
|
-
}
|
|
101
|
-
if (aType === "object") {
|
|
102
|
-
const aKeys = Object.keys(a);
|
|
103
|
-
const bKeys = Object.keys(b);
|
|
104
|
-
const errors = [];
|
|
105
|
-
for (const key of aKeys) {
|
|
106
|
-
if (!b.hasOwnProperty(key)) {
|
|
107
|
-
errors.push({
|
|
108
|
-
path,
|
|
109
|
-
message: `Missing property: ${key} not in right`
|
|
110
|
-
});
|
|
111
|
-
} else {
|
|
112
|
-
errors.push(...deepCompare(a[key], b[key], [...path, key], getCustomComparator));
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
for (const key of bKeys) {
|
|
116
|
-
if (!a.hasOwnProperty(key)) {
|
|
117
|
-
errors.push({
|
|
118
|
-
path,
|
|
119
|
-
message: `Missing property: ${key} not in left`
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return errors;
|
|
124
|
-
}
|
|
125
|
-
return [
|
|
126
|
-
{
|
|
127
|
-
path,
|
|
128
|
-
message: `Value: ${JSON.stringify(a)} != ${JSON.stringify(b)}`
|
|
129
|
-
}
|
|
130
|
-
];
|
|
131
|
-
}
|
|
132
|
-
exports.compareArraysIgnoreOrder = compareArraysIgnoreOrder;
|
|
133
|
-
exports.deepCompare = deepCompare;
|
|
134
|
-
//# sourceMappingURL=deepCompare.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deepCompare.cjs","sources":["../../../../../packages/schema-utils/src/utils/deepCompare.ts"],"sourcesContent":["type Path = (string | number)[]\n\ntype CompareError = {\n\tpath: Path\n\tmessage: string\n}\n\ntype BaseTypes = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function'\ntype ExtendedType = BaseTypes | 'null' | 'array' | 'date' | 'regexp'\n\nconst getType = (val: any): ExtendedType => {\n\tif (val === null) {\n\t\treturn 'null'\n\t}\n\tconst type = typeof val\n\tif (type !== 'object') {\n\t\treturn type\n\t}\n\tif (Array.isArray(val)) {\n\t\treturn 'array'\n\t}\n\tif (val instanceof Date) {\n\t\treturn 'date'\n\t}\n\tif (val instanceof RegExp) {\n\t\treturn 'regexp'\n\t}\n\treturn 'object'\n}\n\ntype Comparator = (a: unknown, b: unknown) => CompareError[]\n\nexport const compareArraysIgnoreOrder = (a: unknown, b: unknown, path: Path) => {\n\tif (!Array.isArray(a) || !Array.isArray(b)) {\n\t\treturn [{ path, message: 'Invalid type, expected array' }]\n\t}\n\tif (a.length !== b.length) {\n\t\treturn [{ path, message: `Array length: ${a.length} != ${b.length}` }]\n\t}\n\tconst haystack = [...b]\n\tfor (const needle of a) {\n\t\tconst index = haystack.findIndex(it => {\n\t\t\tconst errors = deepCompare(needle, it, path)\n\t\t\treturn errors.length === 0\n\t\t})\n\t\tif (index < 0) {\n\t\t\treturn [{ path, message: `Array item: ${JSON.stringify(needle)} not found in ${JSON.stringify(haystack)}` }]\n\t\t}\n\t\thaystack.splice(index, 1)\n\t}\n\tif (haystack.length > 0) {\n\t\treturn [{ path, message: `Array items: ${JSON.stringify(haystack)} not found in ${JSON.stringify(a)}` }]\n\t}\n\treturn []\n}\n\nexport function deepCompare(a: any, b: any, path: Path = [], getCustomComparator?: (path: Path) => Comparator | null): CompareError[] {\n\tif (a === b) {\n\t\treturn []\n\t}\n\tconst comparator = getCustomComparator?.(path)\n\tif (comparator) {\n\t\treturn comparator(a, b)\n\t}\n\n\tconst aType = getType(a)\n\tconst bType = getType(b)\n\tif (aType !== bType) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tpath,\n\t\t\t\tmessage: `Type: ${aType} != ${bType}`,\n\t\t\t},\n\t\t]\n\t}\n\tif (aType === 'array') {\n\t\tconst aLength = (a as any[]).length\n\t\tconst bLength = (b as any[]).length\n\t\tif (aLength !== bLength) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath,\n\t\t\t\t\tmessage: `Array length: ${aLength} != ${bLength}`,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\tconst errors: CompareError[] = []\n\t\tfor (let i = 0; i < aLength; i++) {\n\t\t\terrors.push(...deepCompare(a[i], b[i], [...path, i], getCustomComparator))\n\t\t}\n\t\treturn errors\n\t}\n\n\tif (aType === 'date') {\n\t\tconst aTime = a.getTime()\n\t\tconst bTime = b.getTime()\n\t\tif (aTime == bTime) {\n\t\t\treturn []\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tpath,\n\t\t\t\tmessage: `Time: ${aTime} !== ${bTime}`,\n\t\t\t},\n\t\t]\n\t}\n\tif (aType === 'regexp') {\n\t\tconst aRegexp = a.toString()\n\t\tconst bRegexp = b.toString()\n\t\tif (aRegexp === bRegexp) {\n\t\t\treturn []\n\t\t}\n\t\treturn [{ path, message: `Regexp: ${aRegexp} !== ${bRegexp}` }]\n\t}\n\tif (aType === 'object') {\n\t\tconst aKeys = Object.keys(a)\n\t\tconst bKeys = Object.keys(b)\n\n\t\tconst errors: CompareError[] = []\n\t\tfor (const key of aKeys) {\n\t\t\tif (!b.hasOwnProperty(key)) {\n\t\t\t\terrors.push({\n\t\t\t\t\tpath,\n\t\t\t\t\tmessage: `Missing property: ${key} not in right`,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\terrors.push(...deepCompare(a[key], b[key], [...path, key], getCustomComparator))\n\t\t\t}\n\t\t}\n\t\tfor (const key of bKeys) {\n\t\t\tif (!a.hasOwnProperty(key)) {\n\t\t\t\terrors.push({\n\t\t\t\t\tpath,\n\t\t\t\t\tmessage: `Missing property: ${key} not in left`,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn errors\n\t}\n\treturn [\n\t\t{\n\t\t\tpath,\n\t\t\tmessage: `Value: ${JSON.stringify(a)} != ${JSON.stringify(b)}`,\n\t\t},\n\t]\n}\n"],"names":[],"mappings":";;AAUA,MAAM,UAAU,CAAC,QAA2B;AAC3C,MAAI,QAAQ,MAAM;AACV,WAAA;AAAA,EAAA;AAER,QAAM,OAAO,OAAO;AACpB,MAAI,SAAS,UAAU;AACf,WAAA;AAAA,EAAA;AAEJ,MAAA,MAAM,QAAQ,GAAG,GAAG;AAChB,WAAA;AAAA,EAAA;AAER,MAAI,e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3B,eAAO,KAAK;AAAA,UACX;AAAA,UACA,SAAS,qBAAqB,GAAG;AAAA,QAAA,CACjC;AAAA,MAAA,OACK;AACN,eAAO,KAAK,GAAG,YAAY,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,GAAG,MAAM,GAAG,GAAG,mBAAmB,CAAC;AAAA,MAAA;AAAA,IAChF;AAED,eAAW,OAAO,OAAO;AACxB,UAAI,CAAC,EAAE,eAAe,GAAG,GAAG;AAC3B,eAAO,KAAK;AAAA,UACX;AAAA,UACA,SAAS,qBAAqB,GAAG;AAAA,QAAA,CACjC;AAAA,MAAA;AAAA,IACF;AAEM,WAAA;AAAA,EAAA;AAED,SAAA;AAAA,IACN;AAAA,MACC;AAAA,MACA,SAAS,UAAU,KAAK,UAAU,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;AAAA,IAAA;AAAA,EAE9D;AACD;;;"}
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
const getType = (val) => {
|
|
2
|
-
if (val === null) {
|
|
3
|
-
return "null";
|
|
4
|
-
}
|
|
5
|
-
const type = typeof val;
|
|
6
|
-
if (type !== "object") {
|
|
7
|
-
return type;
|
|
8
|
-
}
|
|
9
|
-
if (Array.isArray(val)) {
|
|
10
|
-
return "array";
|
|
11
|
-
}
|
|
12
|
-
if (val instanceof Date) {
|
|
13
|
-
return "date";
|
|
14
|
-
}
|
|
15
|
-
if (val instanceof RegExp) {
|
|
16
|
-
return "regexp";
|
|
17
|
-
}
|
|
18
|
-
return "object";
|
|
19
|
-
};
|
|
20
|
-
const compareArraysIgnoreOrder = (a, b, path) => {
|
|
21
|
-
if (!Array.isArray(a) || !Array.isArray(b)) {
|
|
22
|
-
return [{ path, message: "Invalid type, expected array" }];
|
|
23
|
-
}
|
|
24
|
-
if (a.length !== b.length) {
|
|
25
|
-
return [{ path, message: `Array length: ${a.length} != ${b.length}` }];
|
|
26
|
-
}
|
|
27
|
-
const haystack = [...b];
|
|
28
|
-
for (const needle of a) {
|
|
29
|
-
const index = haystack.findIndex((it) => {
|
|
30
|
-
const errors = deepCompare(needle, it, path);
|
|
31
|
-
return errors.length === 0;
|
|
32
|
-
});
|
|
33
|
-
if (index < 0) {
|
|
34
|
-
return [{ path, message: `Array item: ${JSON.stringify(needle)} not found in ${JSON.stringify(haystack)}` }];
|
|
35
|
-
}
|
|
36
|
-
haystack.splice(index, 1);
|
|
37
|
-
}
|
|
38
|
-
if (haystack.length > 0) {
|
|
39
|
-
return [{ path, message: `Array items: ${JSON.stringify(haystack)} not found in ${JSON.stringify(a)}` }];
|
|
40
|
-
}
|
|
41
|
-
return [];
|
|
42
|
-
};
|
|
43
|
-
function deepCompare(a, b, path = [], getCustomComparator) {
|
|
44
|
-
if (a === b) {
|
|
45
|
-
return [];
|
|
46
|
-
}
|
|
47
|
-
const comparator = getCustomComparator?.(path);
|
|
48
|
-
if (comparator) {
|
|
49
|
-
return comparator(a, b);
|
|
50
|
-
}
|
|
51
|
-
const aType = getType(a);
|
|
52
|
-
const bType = getType(b);
|
|
53
|
-
if (aType !== bType) {
|
|
54
|
-
return [
|
|
55
|
-
{
|
|
56
|
-
path,
|
|
57
|
-
message: `Type: ${aType} != ${bType}`
|
|
58
|
-
}
|
|
59
|
-
];
|
|
60
|
-
}
|
|
61
|
-
if (aType === "array") {
|
|
62
|
-
const aLength = a.length;
|
|
63
|
-
const bLength = b.length;
|
|
64
|
-
if (aLength !== bLength) {
|
|
65
|
-
return [
|
|
66
|
-
{
|
|
67
|
-
path,
|
|
68
|
-
message: `Array length: ${aLength} != ${bLength}`
|
|
69
|
-
}
|
|
70
|
-
];
|
|
71
|
-
}
|
|
72
|
-
const errors = [];
|
|
73
|
-
for (let i = 0; i < aLength; i++) {
|
|
74
|
-
errors.push(...deepCompare(a[i], b[i], [...path, i], getCustomComparator));
|
|
75
|
-
}
|
|
76
|
-
return errors;
|
|
77
|
-
}
|
|
78
|
-
if (aType === "date") {
|
|
79
|
-
const aTime = a.getTime();
|
|
80
|
-
const bTime = b.getTime();
|
|
81
|
-
if (aTime == bTime) {
|
|
82
|
-
return [];
|
|
83
|
-
}
|
|
84
|
-
return [
|
|
85
|
-
{
|
|
86
|
-
path,
|
|
87
|
-
message: `Time: ${aTime} !== ${bTime}`
|
|
88
|
-
}
|
|
89
|
-
];
|
|
90
|
-
}
|
|
91
|
-
if (aType === "regexp") {
|
|
92
|
-
const aRegexp = a.toString();
|
|
93
|
-
const bRegexp = b.toString();
|
|
94
|
-
if (aRegexp === bRegexp) {
|
|
95
|
-
return [];
|
|
96
|
-
}
|
|
97
|
-
return [{ path, message: `Regexp: ${aRegexp} !== ${bRegexp}` }];
|
|
98
|
-
}
|
|
99
|
-
if (aType === "object") {
|
|
100
|
-
const aKeys = Object.keys(a);
|
|
101
|
-
const bKeys = Object.keys(b);
|
|
102
|
-
const errors = [];
|
|
103
|
-
for (const key of aKeys) {
|
|
104
|
-
if (!b.hasOwnProperty(key)) {
|
|
105
|
-
errors.push({
|
|
106
|
-
path,
|
|
107
|
-
message: `Missing property: ${key} not in right`
|
|
108
|
-
});
|
|
109
|
-
} else {
|
|
110
|
-
errors.push(...deepCompare(a[key], b[key], [...path, key], getCustomComparator));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
for (const key of bKeys) {
|
|
114
|
-
if (!a.hasOwnProperty(key)) {
|
|
115
|
-
errors.push({
|
|
116
|
-
path,
|
|
117
|
-
message: `Missing property: ${key} not in left`
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return errors;
|
|
122
|
-
}
|
|
123
|
-
return [
|
|
124
|
-
{
|
|
125
|
-
path,
|
|
126
|
-
message: `Value: ${JSON.stringify(a)} != ${JSON.stringify(b)}`
|
|
127
|
-
}
|
|
128
|
-
];
|
|
129
|
-
}
|
|
130
|
-
export {
|
|
131
|
-
compareArraysIgnoreOrder,
|
|
132
|
-
deepCompare
|
|
133
|
-
};
|
|
134
|
-
//# sourceMappingURL=deepCompare.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"deepCompare.js","sources":["../../../../../packages/schema-utils/src/utils/deepCompare.ts"],"sourcesContent":["type Path = (string | number)[]\n\ntype CompareError = {\n\tpath: Path\n\tmessage: string\n}\n\ntype BaseTypes = 'string' | 'number' | 'bigint' | 'boolean' | 'symbol' | 'undefined' | 'object' | 'function'\ntype ExtendedType = BaseTypes | 'null' | 'array' | 'date' | 'regexp'\n\nconst getType = (val: any): ExtendedType => {\n\tif (val === null) {\n\t\treturn 'null'\n\t}\n\tconst type = typeof val\n\tif (type !== 'object') {\n\t\treturn type\n\t}\n\tif (Array.isArray(val)) {\n\t\treturn 'array'\n\t}\n\tif (val instanceof Date) {\n\t\treturn 'date'\n\t}\n\tif (val instanceof RegExp) {\n\t\treturn 'regexp'\n\t}\n\treturn 'object'\n}\n\ntype Comparator = (a: unknown, b: unknown) => CompareError[]\n\nexport const compareArraysIgnoreOrder = (a: unknown, b: unknown, path: Path) => {\n\tif (!Array.isArray(a) || !Array.isArray(b)) {\n\t\treturn [{ path, message: 'Invalid type, expected array' }]\n\t}\n\tif (a.length !== b.length) {\n\t\treturn [{ path, message: `Array length: ${a.length} != ${b.length}` }]\n\t}\n\tconst haystack = [...b]\n\tfor (const needle of a) {\n\t\tconst index = haystack.findIndex(it => {\n\t\t\tconst errors = deepCompare(needle, it, path)\n\t\t\treturn errors.length === 0\n\t\t})\n\t\tif (index < 0) {\n\t\t\treturn [{ path, message: `Array item: ${JSON.stringify(needle)} not found in ${JSON.stringify(haystack)}` }]\n\t\t}\n\t\thaystack.splice(index, 1)\n\t}\n\tif (haystack.length > 0) {\n\t\treturn [{ path, message: `Array items: ${JSON.stringify(haystack)} not found in ${JSON.stringify(a)}` }]\n\t}\n\treturn []\n}\n\nexport function deepCompare(a: any, b: any, path: Path = [], getCustomComparator?: (path: Path) => Comparator | null): CompareError[] {\n\tif (a === b) {\n\t\treturn []\n\t}\n\tconst comparator = getCustomComparator?.(path)\n\tif (comparator) {\n\t\treturn comparator(a, b)\n\t}\n\n\tconst aType = getType(a)\n\tconst bType = getType(b)\n\tif (aType !== bType) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tpath,\n\t\t\t\tmessage: `Type: ${aType} != ${bType}`,\n\t\t\t},\n\t\t]\n\t}\n\tif (aType === 'array') {\n\t\tconst aLength = (a as any[]).length\n\t\tconst bLength = (b as any[]).length\n\t\tif (aLength !== bLength) {\n\t\t\treturn [\n\t\t\t\t{\n\t\t\t\t\tpath,\n\t\t\t\t\tmessage: `Array length: ${aLength} != ${bLength}`,\n\t\t\t\t},\n\t\t\t]\n\t\t}\n\t\tconst errors: CompareError[] = []\n\t\tfor (let i = 0; i < aLength; i++) {\n\t\t\terrors.push(...deepCompare(a[i], b[i], [...path, i], getCustomComparator))\n\t\t}\n\t\treturn errors\n\t}\n\n\tif (aType === 'date') {\n\t\tconst aTime = a.getTime()\n\t\tconst bTime = b.getTime()\n\t\tif (aTime == bTime) {\n\t\t\treturn []\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tpath,\n\t\t\t\tmessage: `Time: ${aTime} !== ${bTime}`,\n\t\t\t},\n\t\t]\n\t}\n\tif (aType === 'regexp') {\n\t\tconst aRegexp = a.toString()\n\t\tconst bRegexp = b.toString()\n\t\tif (aRegexp === bRegexp) {\n\t\t\treturn []\n\t\t}\n\t\treturn [{ path, message: `Regexp: ${aRegexp} !== ${bRegexp}` }]\n\t}\n\tif (aType === 'object') {\n\t\tconst aKeys = Object.keys(a)\n\t\tconst bKeys = Object.keys(b)\n\n\t\tconst errors: CompareError[] = []\n\t\tfor (const key of aKeys) {\n\t\t\tif (!b.hasOwnProperty(key)) {\n\t\t\t\terrors.push({\n\t\t\t\t\tpath,\n\t\t\t\t\tmessage: `Missing property: ${key} not in right`,\n\t\t\t\t})\n\t\t\t} else {\n\t\t\t\terrors.push(...deepCompare(a[key], b[key], [...path, key], getCustomComparator))\n\t\t\t}\n\t\t}\n\t\tfor (const key of bKeys) {\n\t\t\tif (!a.hasOwnProperty(key)) {\n\t\t\t\terrors.push({\n\t\t\t\t\tpath,\n\t\t\t\t\tmessage: `Missing property: ${key} not in left`,\n\t\t\t\t})\n\t\t\t}\n\t\t}\n\t\treturn errors\n\t}\n\treturn [\n\t\t{\n\t\t\tpath,\n\t\t\tmessage: `Value: ${JSON.stringify(a)} != ${JSON.stringify(b)}`,\n\t\t},\n\t]\n}\n"],"names":[],"mappings":"AAUA,MAAM,UAAU,CAAC,QAA2B;AAC3C,MAAI,QAAQ,MAAM;AACV,WAAA;AAAA,EAAA;AAER,QAAM,OAAO,OAAO;AACpB,MAAI,SAAS,UAAU;AACf,WAAA;AAAA,EAAA;AAEJ,MAAA,MAAM,QAAQ,GAAG,GAAG;AAChB,WAAA;AAAA,EAAA;AAER,MAAI,eAAe,MAAM;AACjB,WAAA;AAAA,EAAA;AAER,MAAI,eAAe,QAAQ;AACnB,WAAA;AAAA,EAAA;AAED,SAAA;AACR;AAIO,MAAM,2BAA2B,CAAC,GAAY,GAAY,SAAe;AAC3E,MAAA,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,GAAG;AAC3C,WAAO,CAAC,EAAE,MAAM,SAAS,gCAAgC;AAAA,EAAA;AAEtD,MAAA,EAAE,WAAW,EAAE,QAAQ;AACnB,WAAA,CAAC,EAAE,MAAM,SAAS,iBAAiB,EAAE,MAAM,OAAO,EAAE,MAAM,GAAA,CAAI;AAAA,EAAA;AAEhE,QAAA,WAAW,CAAC,GAAG,CAAC;AACtB,aAAW,UAAU,GAAG;AACjB,UAAA,QAAQ,SAAS,UAAU,CAAM,OAAA;AACtC,YAAM,SAAS,YAAY,QAAQ,IAAI,IAAI;AAC3C,aAAO,OAAO,WAAW;AAAA,IAAA,CACzB;AACD,QAAI,QAAQ,GAAG;AACd,aAAO,CAAC,EAAE,MAAM,SAAS,eAAe,KAAK,UAAU,MAAM,CAAC,iBAAiB,KAAK,UAAU,QAAQ,C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MACN;AAAA,QACC;AAAA,QACA,SAAS,SAAS,KAAK,QAAQ,KAAK;AAAA,MAAA;AAAA,IAEtC;AAAA,EAAA;AAED,MAAI,UAAU,UAAU;AACjB,UAAA,UAAU,EAAE,SAAS;AACrB,UAAA,UAAU,EAAE,SAAS;AAC3B,QAAI,YAAY,SAAS;AACxB,aAAO,CAAC;AAAA,IAAA;AAEF,WAAA,CAAC,EAAE,MAAM,SAAS,WAAW,OAAO,QAAQ,OAAO,IAAI;AAAA,EAAA;AAE/D,MAAI,UAAU,UAAU;AACjB,UAAA,QAAQ,OAAO,KAAK,CAAC;AACrB,UAAA,QAAQ,OAAO,KAAK,CAAC;AAE3B,UAAM,SAAyB,CAAC;AAChC,eAAW,OAAO,OAAO;AACxB,UAAI,CAAC,EAAE,eAAe,GAAG,GAAG;AAC3B,eAAO,KAAK;AAAA,UACX;AAAA,UACA,SAAS,qBAAqB,GAAG;AAAA,QAAA,CACjC;AAAA,MAAA,OACK;AACN,eAAO,KAAK,GAAG,YAAY,EAAE,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC,GAAG,MAAM,GAAG,GAAG,mBAAmB,CAAC;AAAA,MAAA;AAAA,IAChF;AAED,eAAW,OAAO,OAAO;AACxB,UAAI,CAAC,EAAE,eAAe,GAAG,GAAG;AAC3B,eAAO,KAAK;AAAA,UACX;AAAA,UACA,SAAS,qBAAqB,GAAG;AAAA,QAAA,CACjC;AAAA,MAAA;AAAA,IACF;AAEM,WAAA;AAAA,EAAA;AAED,SAAA;AAAA,IACN;AAAA,MACC;AAAA,MACA,SAAS,UAAU,KAAK,UAAU,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;AAAA,IAAA;AAAA,EAE9D;AACD;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isIt.cjs","sources":["../../../../../packages/schema-utils/src/utils/isIt.ts"],"sourcesContent":["export const isIt = <T extends object, P extends keyof T = keyof T>(val: any, property: P, value?: T[P]): val is T => {\n\tif (value !== undefined) {\n\t\treturn val[property] === value\n\t}\n\treturn val[property] !== undefined\n}\n"],"names":[],"mappings":";;AAAO,MAAM,OAAO,CAAgD,KAAU,UAAa,UAA2B;AAI9G,SAAA,IAAI,QAAQ,MAAM;AAC1B;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isIt.js","sources":["../../../../../packages/schema-utils/src/utils/isIt.ts"],"sourcesContent":["export const isIt = <T extends object, P extends keyof T = keyof T>(val: any, property: P, value?: T[P]): val is T => {\n\tif (value !== undefined) {\n\t\treturn val[property] === value\n\t}\n\treturn val[property] !== undefined\n}\n"],"names":[],"mappings":"AAAO,MAAM,OAAO,CAAgD,KAAU,UAAa,UAA2B;AAI9G,SAAA,IAAI,QAAQ,MAAM;AAC1B;"}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
class Literal {
|
|
4
|
-
constructor(value) {
|
|
5
|
-
this.value = value;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
const printJsValue = (value, shouldIndentCb = () => false, path = []) => {
|
|
9
|
-
if (value instanceof Literal) {
|
|
10
|
-
return value.value;
|
|
11
|
-
}
|
|
12
|
-
if (value === void 0 || value === null || typeof value === "boolean" || typeof value === "number" || typeof value === "function") {
|
|
13
|
-
return String(value);
|
|
14
|
-
}
|
|
15
|
-
if (typeof value === "bigint") {
|
|
16
|
-
return value.toString(10) + "n";
|
|
17
|
-
}
|
|
18
|
-
if (typeof value === "string") {
|
|
19
|
-
return `'${value.replaceAll(/'/g, "\\'")}'`;
|
|
20
|
-
}
|
|
21
|
-
const shouldIndent = shouldIndentCb(value, path);
|
|
22
|
-
if (!shouldIndent) {
|
|
23
|
-
shouldIndentCb = () => false;
|
|
24
|
-
}
|
|
25
|
-
const indent = (inc) => " ".repeat(path.length + inc);
|
|
26
|
-
const nl = "\n";
|
|
27
|
-
if (Array.isArray(value)) {
|
|
28
|
-
return "[" + value.map(
|
|
29
|
-
(it, index, arr) => (shouldIndent ? nl + indent(1) : "") + printJsValue(it, shouldIndentCb, [...path, { type: "array" }]) + (shouldIndent ? "," : index + 1 < arr.length ? ", " : "")
|
|
30
|
-
).join("") + (shouldIndent ? nl + indent(0) : "") + "]";
|
|
31
|
-
}
|
|
32
|
-
return "{" + (shouldIndent ? "" : " ") + Object.entries(value).map(([key, value2], index, arr) => {
|
|
33
|
-
const formattedKey = isSimpleIdentifier(key) ? key : `[${printJsValue(key)}]`;
|
|
34
|
-
return "" + (shouldIndent ? nl + indent(1) : "") + formattedKey + ": " + printJsValue(value2, shouldIndentCb, [...path, { type: "object", key }]) + (shouldIndent ? "," : index + 1 < arr.length ? ", " : "");
|
|
35
|
-
}).join("") + (shouldIndent ? nl + indent(0) : " ") + "}";
|
|
36
|
-
};
|
|
37
|
-
const isSimpleIdentifier = (identifier) => {
|
|
38
|
-
return !!identifier.match(/^[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*$/);
|
|
39
|
-
};
|
|
40
|
-
exports.Literal = Literal;
|
|
41
|
-
exports.printJsValue = printJsValue;
|
|
42
|
-
//# sourceMappingURL=printJsValue.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"printJsValue.cjs","sources":["../../../../../packages/schema-utils/src/utils/printJsValue.ts"],"sourcesContent":["export class Literal {\n\tconstructor(public readonly value: string) {\n\t}\n}\n\nexport type FormatterPath = ({ type: 'array' } | { type: 'object'; key: string })[]\nexport type IndentDecider = (value: any, path: FormatterPath) => boolean\n\n\nexport const printJsValue = (value: any, shouldIndentCb: IndentDecider = () => false, path: FormatterPath = []): string => {\n\tif (value instanceof Literal) {\n\t\treturn value.value\n\t}\n\tif (value === undefined || value === null || typeof value === 'boolean' || typeof value === 'number' || typeof value === 'function') {\n\t\treturn String(value)\n\t}\n\tif (typeof value === 'bigint') {\n\t\treturn value.toString(10) + 'n'\n\t}\n\tif (typeof value === 'string') {\n\t\treturn `'${value.replaceAll(/'/g, '\\\\\\'')}'`\n\t}\n\tconst shouldIndent = shouldIndentCb(value, path)\n\tif (!shouldIndent) {\n\t\tshouldIndentCb = () => false\n\t}\n\n\tconst indent = (inc: number) => '\\t'.repeat(path.length + inc)\n\tconst nl = '\\n'\n\n\tif (Array.isArray(value)) {\n\t\treturn ''\n\t\t\t\t+ '['\n\t\t\t\t+ value.map((it, index, arr) =>\n\t\t\t\t\t(shouldIndent ? nl + indent(1) : '')\n\t\t\t\t\t+ printJsValue(it, shouldIndentCb, [...path, { type: 'array' }])\n\t\t\t\t\t+ (shouldIndent ? ',' : ((index + 1) < arr.length ? ', ' : '')),\n\t\t\t\t).join('')\n\t\t\t\t+ (shouldIndent ? nl + indent(0) : '')\n\t\t\t\t+ ']'\n\t}\n\n\treturn ''\n\t\t\t+ '{'\n\t\t\t+ (shouldIndent ? '' : ' ')\n\t\t\t+ Object.entries(value).map(([key, value], index, arr) => {\n\t\t\t\tconst formattedKey = isSimpleIdentifier(key) ? key : `[${printJsValue(key)}]`\n\t\t\t\treturn ''\n\t\t\t\t\t+ (shouldIndent ? nl + indent(1) : '')\n\t\t\t\t\t+ formattedKey\n\t\t\t\t\t+ ': '\n\t\t\t\t\t+ printJsValue(value, shouldIndentCb, [...path, { type: 'object', key }])\n\t\t\t\t\t+ (shouldIndent ? ',' : ((index + 1) < arr.length ? ', ' : ''))\n\t\t\t}).join('')\n\t\t\t+ (shouldIndent ? nl + indent(0) : ' ')\n\t\t\t+ '}'\n\n}\n\nconst isSimpleIdentifier = (identifier: string): boolean => {\n\treturn !!identifier.match(/^[_$a-zA-Z\\xA0-\\uFFFF][_$a-zA-Z0-9\\xA0-\\uFFFF]*$/)\n}\n"],"names":["value"],"mappings":";;AAAO,MAAM,QAAQ;AAAA,EACpB,YAA4B,OAAe;AAAf,SAAA,QAAA;AAAA,EAAA;AAE7B;AAMa,MAAA,eAAe,CAAC,OAA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