@blazetrails/activemodel 0.0.0-stage → 0.1.0-alpha0.1
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/LICENSE +21 -0
- package/dist/access.d.ts +6 -0
- package/dist/access.js +11 -0
- package/dist/access.js.map +1 -0
- package/dist/api.d.ts +55 -0
- package/dist/api.js +28 -0
- package/dist/api.js.map +1 -0
- package/dist/attribute/user-provided-default.d.ts +13 -0
- package/dist/attribute/user-provided-default.js +44 -0
- package/dist/attribute/user-provided-default.js.map +1 -0
- package/dist/attribute-assignment.d.ts +47 -0
- package/dist/attribute-assignment.js +182 -0
- package/dist/attribute-assignment.js.map +1 -0
- package/dist/attribute-methods.d.ts +231 -0
- package/dist/attribute-methods.js +421 -0
- package/dist/attribute-methods.js.map +1 -0
- package/dist/attribute-mutation-tracker.d.ts +64 -0
- package/dist/attribute-mutation-tracker.js +167 -0
- package/dist/attribute-mutation-tracker.js.map +1 -0
- package/dist/attribute-registration.d.ts +121 -0
- package/dist/attribute-registration.js +159 -0
- package/dist/attribute-registration.js.map +1 -0
- package/dist/attribute-set/builder.d.ts +70 -0
- package/dist/attribute-set/builder.js +212 -0
- package/dist/attribute-set/builder.js.map +1 -0
- package/dist/attribute-set/yaml-encoder.d.ts +12 -0
- package/dist/attribute-set/yaml-encoder.js +35 -0
- package/dist/attribute-set/yaml-encoder.js.map +1 -0
- package/dist/attribute-set.d.ts +40 -0
- package/dist/attribute-set.js +106 -0
- package/dist/attribute-set.js.map +1 -0
- package/dist/attribute.d.ts +93 -0
- package/dist/attribute.js +261 -0
- package/dist/attribute.js.map +1 -0
- package/dist/attributes.d.ts +77 -0
- package/dist/attributes.js +78 -0
- package/dist/attributes.js.map +1 -0
- package/dist/callbacks.d.ts +48 -0
- package/dist/callbacks.js +73 -0
- package/dist/callbacks.js.map +1 -0
- package/dist/constants.generated.d.ts +2 -0
- package/dist/constants.generated.js +183 -0
- package/dist/constants.generated.js.map +1 -0
- package/dist/conversion.d.ts +41 -0
- package/dist/conversion.js +40 -0
- package/dist/conversion.js.map +1 -0
- package/dist/deprecator.d.ts +7 -0
- package/dist/deprecator.js +7 -0
- package/dist/deprecator.js.map +1 -0
- package/dist/dirty.d.ts +79 -0
- package/dist/dirty.js +138 -0
- package/dist/dirty.js.map +1 -0
- package/dist/error.d.ts +27 -0
- package/dist/error.js +223 -0
- package/dist/error.js.map +1 -0
- package/dist/errors.d.ts +81 -0
- package/dist/errors.js +215 -0
- package/dist/errors.js.map +1 -0
- package/dist/forbidden-attributes-protection.d.ts +16 -0
- package/dist/forbidden-attributes-protection.js +22 -0
- package/dist/forbidden-attributes-protection.js.map +1 -0
- package/dist/gem-version.d.ts +10 -0
- package/dist/gem-version.js +16 -0
- package/dist/gem-version.js.map +1 -0
- package/dist/i18n.d.ts +3 -0
- package/dist/i18n.js +7 -0
- package/dist/i18n.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.js +59 -0
- package/dist/index.js.map +1 -0
- package/dist/lint.d.ts +60 -0
- package/dist/lint.js +58 -0
- package/dist/lint.js.map +1 -0
- package/dist/locale/en.d.ts +2 -0
- package/dist/locale/en.js +41 -0
- package/dist/locale/en.js.map +1 -0
- package/dist/model.d.ts +90 -0
- package/dist/model.js +47 -0
- package/dist/model.js.map +1 -0
- package/dist/namespaces.d.ts +27 -0
- package/dist/namespaces.js +37 -0
- package/dist/namespaces.js.map +1 -0
- package/dist/naming.d.ts +76 -0
- package/dist/naming.js +198 -0
- package/dist/naming.js.map +1 -0
- package/dist/nested-error.d.ts +18 -0
- package/dist/nested-error.js +17 -0
- package/dist/nested-error.js.map +1 -0
- package/dist/secure-password.d.ts +31 -0
- package/dist/secure-password.js +164 -0
- package/dist/secure-password.js.map +1 -0
- package/dist/serialization.d.ts +40 -0
- package/dist/serialization.js +226 -0
- package/dist/serialization.js.map +1 -0
- package/dist/serializers/json.d.ts +27 -0
- package/dist/serializers/json.js +43 -0
- package/dist/serializers/json.js.map +1 -0
- package/dist/translation.d.ts +27 -0
- package/dist/translation.js +64 -0
- package/dist/translation.js.map +1 -0
- package/dist/type/big-integer.d.ts +6 -0
- package/dist/type/big-integer.js +10 -0
- package/dist/type/big-integer.js.map +1 -0
- package/dist/type/binary.d.ts +19 -0
- package/dist/type/binary.js +56 -0
- package/dist/type/binary.js.map +1 -0
- package/dist/type/boolean.d.ts +10 -0
- package/dist/type/boolean.js +38 -0
- package/dist/type/boolean.js.map +1 -0
- package/dist/type/date-time.d.ts +23 -0
- package/dist/type/date-time.js +54 -0
- package/dist/type/date-time.js.map +1 -0
- package/dist/type/date.d.ts +27 -0
- package/dist/type/date.js +78 -0
- package/dist/type/date.js.map +1 -0
- package/dist/type/decimal.d.ts +28 -0
- package/dist/type/decimal.js +71 -0
- package/dist/type/decimal.js.map +1 -0
- package/dist/type/float.d.ts +19 -0
- package/dist/type/float.js +38 -0
- package/dist/type/float.js.map +1 -0
- package/dist/type/helpers/accepts-multiparameter-time.d.ts +25 -0
- package/dist/type/helpers/accepts-multiparameter-time.js +50 -0
- package/dist/type/helpers/accepts-multiparameter-time.js.map +1 -0
- package/dist/type/helpers/mutable.d.ts +10 -0
- package/dist/type/helpers/mutable.js +13 -0
- package/dist/type/helpers/mutable.js.map +1 -0
- package/dist/type/helpers/numeric.d.ts +23 -0
- package/dist/type/helpers/numeric.js +50 -0
- package/dist/type/helpers/numeric.js.map +1 -0
- package/dist/type/helpers/time-value.d.ts +31 -0
- package/dist/type/helpers/time-value.js +100 -0
- package/dist/type/helpers/time-value.js.map +1 -0
- package/dist/type/helpers/timezone.d.ts +5 -0
- package/dist/type/helpers/timezone.js +16 -0
- package/dist/type/helpers/timezone.js.map +1 -0
- package/dist/type/helpers.d.ts +6 -0
- package/dist/type/helpers.js +6 -0
- package/dist/type/helpers.js.map +1 -0
- package/dist/type/immutable-string.d.ts +19 -0
- package/dist/type/immutable-string.js +43 -0
- package/dist/type/immutable-string.js.map +1 -0
- package/dist/type/integer.d.ts +43 -0
- package/dist/type/integer.js +82 -0
- package/dist/type/integer.js.map +1 -0
- package/dist/type/internal/sentinels.d.ts +12 -0
- package/dist/type/internal/sentinels.js +3 -0
- package/dist/type/internal/sentinels.js.map +1 -0
- package/dist/type/registry.d.ts +19 -0
- package/dist/type/registry.js +35 -0
- package/dist/type/registry.js.map +1 -0
- package/dist/type/serialize-cast-value.d.ts +32 -0
- package/dist/type/serialize-cast-value.js +56 -0
- package/dist/type/serialize-cast-value.js.map +1 -0
- package/dist/type/string.d.ts +8 -0
- package/dist/type/string.js +30 -0
- package/dist/type/string.js.map +1 -0
- package/dist/type/time.d.ts +16 -0
- package/dist/type/time.js +62 -0
- package/dist/type/time.js.map +1 -0
- package/dist/type/value.d.ts +42 -0
- package/dist/type/value.js +93 -0
- package/dist/type/value.js.map +1 -0
- package/dist/type.d.ts +10 -0
- package/dist/type.js +47 -0
- package/dist/type.js.map +1 -0
- package/dist/validations/absence.d.ts +10 -0
- package/dist/validations/absence.js +15 -0
- package/dist/validations/absence.js.map +1 -0
- package/dist/validations/acceptance.d.ts +37 -0
- package/dist/validations/acceptance.js +65 -0
- package/dist/validations/acceptance.js.map +1 -0
- package/dist/validations/callbacks.d.ts +45 -0
- package/dist/validations/callbacks.js +42 -0
- package/dist/validations/callbacks.js.map +1 -0
- package/dist/validations/clusivity.d.ts +37 -0
- package/dist/validations/clusivity.js +55 -0
- package/dist/validations/clusivity.js.map +1 -0
- package/dist/validations/comparability.d.ts +27 -0
- package/dist/validations/comparability.js +17 -0
- package/dist/validations/comparability.js.map +1 -0
- package/dist/validations/comparison.d.ts +15 -0
- package/dist/validations/comparison.js +41 -0
- package/dist/validations/comparison.js.map +1 -0
- package/dist/validations/confirmation.d.ts +29 -0
- package/dist/validations/confirmation.js +48 -0
- package/dist/validations/confirmation.js.map +1 -0
- package/dist/validations/exclusion.d.ts +13 -0
- package/dist/validations/exclusion.js +25 -0
- package/dist/validations/exclusion.js.map +1 -0
- package/dist/validations/format.d.ts +30 -0
- package/dist/validations/format.js +80 -0
- package/dist/validations/format.js.map +1 -0
- package/dist/validations/helper-methods.d.ts +24 -0
- package/dist/validations/helper-methods.js +32 -0
- package/dist/validations/helper-methods.js.map +1 -0
- package/dist/validations/inclusion.d.ts +13 -0
- package/dist/validations/inclusion.js +25 -0
- package/dist/validations/inclusion.js.map +1 -0
- package/dist/validations/length.d.ts +23 -0
- package/dist/validations/length.js +106 -0
- package/dist/validations/length.js.map +1 -0
- package/dist/validations/numericality.d.ts +76 -0
- package/dist/validations/numericality.js +196 -0
- package/dist/validations/numericality.js.map +1 -0
- package/dist/validations/presence.d.ts +10 -0
- package/dist/validations/presence.js +15 -0
- package/dist/validations/presence.js.map +1 -0
- package/dist/validations/resolve-value.d.ts +8 -0
- package/dist/validations/resolve-value.js +24 -0
- package/dist/validations/resolve-value.js.map +1 -0
- package/dist/validations/validates.d.ts +13 -0
- package/dist/validations/validates.js +53 -0
- package/dist/validations/validates.js.map +1 -0
- package/dist/validations/with.d.ts +21 -0
- package/dist/validations/with.js +44 -0
- package/dist/validations/with.js.map +1 -0
- package/dist/validations.d.ts +138 -0
- package/dist/validations.js +239 -0
- package/dist/validations.js.map +1 -0
- package/dist/validator.d.ts +31 -0
- package/dist/validator.js +62 -0
- package/dist/validator.js.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/package.json +61 -3
- package/README.md +0 -3
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export { Access } from "./access.js";
|
|
2
|
+
export { ActiveModel } from "./namespaces.js";
|
|
3
|
+
export { Model } from "./model.js";
|
|
4
|
+
export { I18n } from "./i18n.js";
|
|
5
|
+
export { Error } from "./error.js";
|
|
6
|
+
export { deprecator, Deprecator } from "./deprecator.js";
|
|
7
|
+
export { Errors, StrictValidationFailed, UnknownAttributeError, RangeError } from "./errors.js";
|
|
8
|
+
export { NestedError } from "./nested-error.js";
|
|
9
|
+
export { ValidationError, ValidationContext } from "./validations.js";
|
|
10
|
+
export type { ModelWithErrors } from "./validations.js";
|
|
11
|
+
export { Validator, EachValidator, BlockValidator } from "./validator.js";
|
|
12
|
+
export { MissingAttributeError, AttributeMethodPattern, AttrNames, completeHalfAccessor, } from "./attribute-methods.js";
|
|
13
|
+
export * as AttributeMethods from "./attribute-methods.js";
|
|
14
|
+
export type { InstanceHost } from "./attribute-methods.js";
|
|
15
|
+
export { ForbiddenAttributesError, sanitizeForMassAssignment, } from "./forbidden-attributes-protection.js";
|
|
16
|
+
export type { PermittedAttributes } from "./forbidden-attributes-protection.js";
|
|
17
|
+
export { assignAttributes, assertAssignedSynchronously, assigningSynchronously, awaitingAssignment, capturingAssignment, deferringToAssignment, attributeWriterMissing, ArgumentError, NoMethodError, RuntimeError, } from "./attribute-assignment.js";
|
|
18
|
+
export type { AttributeAssignment } from "./attribute-assignment.js";
|
|
19
|
+
export { AttributeMutationTracker, ForcedMutationTracker, NullMutationTracker, } from "./attribute-mutation-tracker.js";
|
|
20
|
+
export { AttributeRegistration, PendingDefault, PendingType } from "./attribute-registration.js";
|
|
21
|
+
export { Attributes } from "./attributes.js";
|
|
22
|
+
export type { AttributeOptions, AttributesClassHalf, AttributeMethodsClassHalf, AttributeRegistrationClassHalf, } from "./attributes.js";
|
|
23
|
+
export { Attribute, FromDatabase, FromUser, WithCastValue, UNINITIALIZED_ORIGINAL_VALUE, } from "./attribute.js";
|
|
24
|
+
export { UserProvidedDefault } from "./attribute/user-provided-default.js";
|
|
25
|
+
export { AttributeSet } from "./attribute-set.js";
|
|
26
|
+
export { LazyAttributeSet, LazyAttributeHash } from "./attribute-set/builder.js";
|
|
27
|
+
export { YAMLEncoder } from "./attribute-set/yaml-encoder.js";
|
|
28
|
+
export { WithValidator } from "./validations/with.js";
|
|
29
|
+
export { AbsenceValidator } from "./validations/absence.js";
|
|
30
|
+
export type { AttrNameArg } from "./validations/helper-methods.js";
|
|
31
|
+
export { Callbacks as ValidationsCallbacks } from "./validations/callbacks.js";
|
|
32
|
+
export { PresenceValidator } from "./validations/presence.js";
|
|
33
|
+
export { LengthValidator } from "./validations/length.js";
|
|
34
|
+
export { NumericalityValidator } from "./validations/numericality.js";
|
|
35
|
+
export { AcceptsMultiparameterTime } from "./type/helpers/accepts-multiparameter-time.js";
|
|
36
|
+
export { Mutable } from "./type/helpers/mutable.js";
|
|
37
|
+
export { ModelName, Naming } from "./naming.js";
|
|
38
|
+
export { Conversion } from "./conversion.js";
|
|
39
|
+
export { VERSION, gemVersion } from "./gem-version.js";
|
|
40
|
+
export { version } from "./version.js";
|
|
41
|
+
export { Translation } from "./translation.js";
|
|
42
|
+
export type { ModelLike } from "./naming.js";
|
|
43
|
+
export { Dirty } from "./dirty.js";
|
|
44
|
+
export type { DirtyOptions } from "./dirty.js";
|
|
45
|
+
export { Callbacks } from "./callbacks.js";
|
|
46
|
+
export type { CallbackConditions, CallbackObject, TransactionalCallbackConditions, } from "./callbacks.js";
|
|
47
|
+
export { serializableHash } from "./serialization.js";
|
|
48
|
+
export type { SerializeOptions, SerializableHash } from "./serialization.js";
|
|
49
|
+
export { JSON as JSONSerializer } from "./serializers/json.js";
|
|
50
|
+
export { StringType } from "./type/string.js";
|
|
51
|
+
export { IntegerType } from "./type/integer.js";
|
|
52
|
+
export { FloatType } from "./type/float.js";
|
|
53
|
+
export { BooleanType } from "./type/boolean.js";
|
|
54
|
+
export { DateType } from "./type/date.js";
|
|
55
|
+
export type { DateCastResult } from "./type/date.js";
|
|
56
|
+
export { DateTimeType } from "./type/date-time.js";
|
|
57
|
+
export type { DateTimeCastResult } from "./type/date-time.js";
|
|
58
|
+
export { DecimalType } from "./type/decimal.js";
|
|
59
|
+
export { BigIntegerType } from "./type/big-integer.js";
|
|
60
|
+
export { ImmutableStringType } from "./type/immutable-string.js";
|
|
61
|
+
export { ValueType } from "./type/value.js";
|
|
62
|
+
export { BinaryType, Data as BinaryData } from "./type/binary.js";
|
|
63
|
+
export { TimeType } from "./type/time.js";
|
|
64
|
+
export { defaultValue } from "./type.js";
|
|
65
|
+
export * as Type from "./type.js";
|
|
66
|
+
export { hasSecurePassword, SecurePassword, InstanceMethodsOnActivation, } from "./secure-password.js";
|
|
67
|
+
export { SerializeCastValue } from "./type/serialize-cast-value.js";
|
|
68
|
+
export { Builder as AttributeSetBuilder } from "./attribute-set/builder.js";
|
|
69
|
+
export { DateInfinity, DateNegativeInfinity } from "./type/internal/sentinels.js";
|
|
70
|
+
export type { DateInfinity as DateInfinityType, DateNegativeInfinity as DateNegativeInfinityType, } from "./type/internal/sentinels.js";
|
|
71
|
+
import "./constants.generated.js";
|
|
72
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export { Access } from "./access.js";
|
|
2
|
+
export { ActiveModel } from "./namespaces.js";
|
|
3
|
+
export { Model } from "./model.js";
|
|
4
|
+
export { I18n } from "./i18n.js";
|
|
5
|
+
export { Error } from "./error.js";
|
|
6
|
+
export { deprecator, Deprecator } from "./deprecator.js";
|
|
7
|
+
export { Errors, StrictValidationFailed, UnknownAttributeError, RangeError } from "./errors.js";
|
|
8
|
+
export { NestedError } from "./nested-error.js";
|
|
9
|
+
export { ValidationError, ValidationContext } from "./validations.js";
|
|
10
|
+
export { Validator, EachValidator, BlockValidator } from "./validator.js";
|
|
11
|
+
export { MissingAttributeError, AttributeMethodPattern, AttrNames, completeHalfAccessor, } from "./attribute-methods.js";
|
|
12
|
+
export * as AttributeMethods from "./attribute-methods.js";
|
|
13
|
+
export { ForbiddenAttributesError, sanitizeForMassAssignment, } from "./forbidden-attributes-protection.js";
|
|
14
|
+
export { assignAttributes, assertAssignedSynchronously, assigningSynchronously, awaitingAssignment, capturingAssignment, deferringToAssignment, attributeWriterMissing, ArgumentError, NoMethodError, RuntimeError, } from "./attribute-assignment.js";
|
|
15
|
+
export { AttributeMutationTracker, ForcedMutationTracker, NullMutationTracker, } from "./attribute-mutation-tracker.js";
|
|
16
|
+
export { AttributeRegistration, PendingDefault, PendingType } from "./attribute-registration.js";
|
|
17
|
+
export { Attributes } from "./attributes.js";
|
|
18
|
+
export { Attribute, FromDatabase, FromUser, WithCastValue, UNINITIALIZED_ORIGINAL_VALUE, } from "./attribute.js";
|
|
19
|
+
export { UserProvidedDefault } from "./attribute/user-provided-default.js";
|
|
20
|
+
export { AttributeSet } from "./attribute-set.js";
|
|
21
|
+
export { LazyAttributeSet, LazyAttributeHash } from "./attribute-set/builder.js";
|
|
22
|
+
export { YAMLEncoder } from "./attribute-set/yaml-encoder.js";
|
|
23
|
+
export { WithValidator } from "./validations/with.js";
|
|
24
|
+
export { AbsenceValidator } from "./validations/absence.js";
|
|
25
|
+
export { Callbacks as ValidationsCallbacks } from "./validations/callbacks.js";
|
|
26
|
+
export { PresenceValidator } from "./validations/presence.js";
|
|
27
|
+
export { LengthValidator } from "./validations/length.js";
|
|
28
|
+
export { NumericalityValidator } from "./validations/numericality.js";
|
|
29
|
+
export { AcceptsMultiparameterTime } from "./type/helpers/accepts-multiparameter-time.js";
|
|
30
|
+
export { Mutable } from "./type/helpers/mutable.js";
|
|
31
|
+
export { ModelName, Naming } from "./naming.js";
|
|
32
|
+
export { Conversion } from "./conversion.js";
|
|
33
|
+
export { VERSION, gemVersion } from "./gem-version.js";
|
|
34
|
+
export { version } from "./version.js";
|
|
35
|
+
export { Translation } from "./translation.js";
|
|
36
|
+
export { Dirty } from "./dirty.js";
|
|
37
|
+
export { Callbacks } from "./callbacks.js";
|
|
38
|
+
export { serializableHash } from "./serialization.js";
|
|
39
|
+
export { JSON as JSONSerializer } from "./serializers/json.js";
|
|
40
|
+
export { StringType } from "./type/string.js";
|
|
41
|
+
export { IntegerType } from "./type/integer.js";
|
|
42
|
+
export { FloatType } from "./type/float.js";
|
|
43
|
+
export { BooleanType } from "./type/boolean.js";
|
|
44
|
+
export { DateType } from "./type/date.js";
|
|
45
|
+
export { DateTimeType } from "./type/date-time.js";
|
|
46
|
+
export { DecimalType } from "./type/decimal.js";
|
|
47
|
+
export { BigIntegerType } from "./type/big-integer.js";
|
|
48
|
+
export { ImmutableStringType } from "./type/immutable-string.js";
|
|
49
|
+
export { ValueType } from "./type/value.js";
|
|
50
|
+
export { BinaryType, Data as BinaryData } from "./type/binary.js";
|
|
51
|
+
export { TimeType } from "./type/time.js";
|
|
52
|
+
export { defaultValue } from "./type.js";
|
|
53
|
+
export * as Type from "./type.js";
|
|
54
|
+
export { hasSecurePassword, SecurePassword, InstanceMethodsOnActivation, } from "./secure-password.js";
|
|
55
|
+
export { SerializeCastValue } from "./type/serialize-cast-value.js";
|
|
56
|
+
export { Builder as AttributeSetBuilder } from "./attribute-set/builder.js";
|
|
57
|
+
export { DateInfinity, DateNegativeInfinity } from "./type/internal/sentinels.js";
|
|
58
|
+
import "./constants.generated.js";
|
|
59
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,sBAAsB,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAChG,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAEtE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC1E,OAAO,E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AAC;AAE1C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAElC,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,2BAA2B,GAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAMlF,OAAO,0BAA0B,CAAC"}
|
package/dist/lint.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export interface Lint {
|
|
2
|
+
}
|
|
3
|
+
/** @internal */
|
|
4
|
+
export declare function model<T>(model: {
|
|
5
|
+
toModel(): T;
|
|
6
|
+
}): T;
|
|
7
|
+
/** @internal */
|
|
8
|
+
export declare function assertBoolean(result: unknown, name: string): void;
|
|
9
|
+
export declare namespace Tests {
|
|
10
|
+
type ToKeyHost = {
|
|
11
|
+
toKey(): unknown[] | null;
|
|
12
|
+
isPersisted(): boolean;
|
|
13
|
+
};
|
|
14
|
+
export function testToKey(input: {
|
|
15
|
+
toModel(): ToKeyHost;
|
|
16
|
+
}): void;
|
|
17
|
+
type ToParamHost = {
|
|
18
|
+
toParam(): string | null;
|
|
19
|
+
toKey(): unknown[] | null;
|
|
20
|
+
isPersisted(): boolean;
|
|
21
|
+
};
|
|
22
|
+
export function testToParam(input: {
|
|
23
|
+
toModel(): ToParamHost;
|
|
24
|
+
}): void;
|
|
25
|
+
type ToPartialPathHost = {
|
|
26
|
+
toPartialPath(): string;
|
|
27
|
+
};
|
|
28
|
+
export function testToPartialPath(input: {
|
|
29
|
+
toModel(): ToPartialPathHost;
|
|
30
|
+
}): void;
|
|
31
|
+
type PersistedHost = {
|
|
32
|
+
isPersisted(): boolean;
|
|
33
|
+
};
|
|
34
|
+
export function testPersisted(input: {
|
|
35
|
+
toModel(): PersistedHost;
|
|
36
|
+
}): void;
|
|
37
|
+
type ModelName = {
|
|
38
|
+
human(): string;
|
|
39
|
+
singular: string;
|
|
40
|
+
plural: string;
|
|
41
|
+
};
|
|
42
|
+
type ModelNamingHost = {
|
|
43
|
+
modelName: ModelName;
|
|
44
|
+
constructor: object;
|
|
45
|
+
};
|
|
46
|
+
export function testModelNaming(input: {
|
|
47
|
+
toModel(): ModelNamingHost;
|
|
48
|
+
}): void;
|
|
49
|
+
type ErrorsArefHost = {
|
|
50
|
+
errors: {
|
|
51
|
+
get(attribute: string): unknown;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
export function testErrorsAref(input: {
|
|
55
|
+
toModel(): ErrorsArefHost;
|
|
56
|
+
}): void;
|
|
57
|
+
export {};
|
|
58
|
+
}
|
|
59
|
+
export declare const { testToKey, testToParam, testToPartialPath, testPersisted, testModelNaming, testErrorsAref, }: typeof Tests;
|
|
60
|
+
//# sourceMappingURL=lint.d.ts.map
|
package/dist/lint.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { ActiveModel } from "./namespaces.js";
|
|
2
|
+
import * as LintModule from "./lint.js";
|
|
3
|
+
import { assert, assertEqual, assertKindOf, assertRespondTo, } from "@blazetrails/activesupport/testing/assertions";
|
|
4
|
+
/** @internal */
|
|
5
|
+
export function model(model) {
|
|
6
|
+
assertRespondTo(model, "toModel");
|
|
7
|
+
return model.toModel();
|
|
8
|
+
}
|
|
9
|
+
/** @internal */
|
|
10
|
+
export function assertBoolean(result, name) {
|
|
11
|
+
assert(result === true || result === false, `${name} should be a boolean`);
|
|
12
|
+
}
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-namespace
|
|
14
|
+
export var Tests;
|
|
15
|
+
(function (Tests) {
|
|
16
|
+
function testToKey(input) {
|
|
17
|
+
assertRespondTo(model(input), "toKey");
|
|
18
|
+
model(input).isPersisted = () => false;
|
|
19
|
+
assert(model(input).toKey() == null, "to_key should return nil when `persisted?` returns false");
|
|
20
|
+
}
|
|
21
|
+
Tests.testToKey = testToKey;
|
|
22
|
+
function testToParam(input) {
|
|
23
|
+
assertRespondTo(model(input), "toParam");
|
|
24
|
+
model(input).toKey = () => [1];
|
|
25
|
+
model(input).isPersisted = () => false;
|
|
26
|
+
assert(model(input).toParam() == null, "to_param should return nil when `persisted?` returns false");
|
|
27
|
+
}
|
|
28
|
+
Tests.testToParam = testToParam;
|
|
29
|
+
function testToPartialPath(input) {
|
|
30
|
+
assertRespondTo(model(input), "toPartialPath");
|
|
31
|
+
assertKindOf(String, model(input).toPartialPath());
|
|
32
|
+
}
|
|
33
|
+
Tests.testToPartialPath = testToPartialPath;
|
|
34
|
+
function testPersisted(input) {
|
|
35
|
+
assertRespondTo(model(input), "isPersisted");
|
|
36
|
+
assertBoolean(model(input).isPersisted(), "persisted?");
|
|
37
|
+
}
|
|
38
|
+
Tests.testPersisted = testPersisted;
|
|
39
|
+
function testModelNaming(input) {
|
|
40
|
+
assertRespondTo(model(input).constructor, "modelName");
|
|
41
|
+
const modelName = model(input).constructor.modelName;
|
|
42
|
+
assertRespondTo(modelName, "toString");
|
|
43
|
+
assertRespondTo(modelName.human(), "toStr");
|
|
44
|
+
assertRespondTo(modelName.singular, "toStr");
|
|
45
|
+
assertRespondTo(modelName.plural, "toStr");
|
|
46
|
+
assertRespondTo(model(input), "modelName");
|
|
47
|
+
assertEqual(model(input).modelName, model(input).constructor.modelName);
|
|
48
|
+
}
|
|
49
|
+
Tests.testModelNaming = testModelNaming;
|
|
50
|
+
function testErrorsAref(input) {
|
|
51
|
+
assertRespondTo(model(input), "errors");
|
|
52
|
+
assertEqual([], model(input).errors.get("hello"), "errors#[] should return an empty Array");
|
|
53
|
+
}
|
|
54
|
+
Tests.testErrorsAref = testErrorsAref;
|
|
55
|
+
})(Tests || (Tests = {}));
|
|
56
|
+
export const { testToKey, testToParam, testToPartialPath, testPersisted, testModelNaming, testErrorsAref, } = Tests;
|
|
57
|
+
ActiveModel.Lint = LintModule;
|
|
58
|
+
//# sourceMappingURL=lint.js.map
|
package/dist/lint.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../lib/lint.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,UAAU,MAAM,WAAW,CAAC;AACxC,OAAO,EACL,MAAM,EACN,WAAW,EACX,YAAY,EACZ,eAAe,GAChB,MAAM,+CAA+C,CAAC;AAKvD,gBAAgB;AAChB,MAAM,UAAU,KAAK,CAAI,KAAuB;IAC9C,eAAe,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IAClC,OAAO,KAAK,CAAC,OAAO,EAAE,CAAC;AACzB,CAAC;AAED,gBAAgB;AAChB,MAAM,UAAU,aAAa,CAAC,MAAe,EAAE,IAAY;IACzD,MAAM,CAAC,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,KAAK,EAAE,GAAG,IAAI,sBAAsB,CAAC,CAAC;AAC7E,CAAC;AAED,2DAA2D;AAC3D,MAAM,KAAW,KAAK,CA4DrB;AA5DD,WAAiB,KAAK;IAEpB,SAAgB,SAAS,CAAC,KAA+B;QACvD,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;QACvC,KAAK,CAAC,KAAK,CAAC,CAAC,WAAW,GAAG,GAAG,EAAE,CAAC,KAAK,CAAC;QACvC,MAAM,CACJ,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,IAAI,IAAI,EAC5B,0DAA0D,CAC3D,CAAC;IACJ,CAAC;IAPe,MAAA,SAAS,YAOxB,CAAA;IAOD,SAAgB,WAAW,CAAC,KAAiC;QAC3D,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC,CAAC;QACzC,KAAK,CAAC,KAAK,CAAC,CAAC,KAAK,GAAG,GAAG,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CACT,KAAK,CAAC,KAAK,CAAC,CAAC,SAAS,EACrB,KAAK,CAAC,KAAK,CAAC,CAAC,WAAwC,CAAC,SAAS,CACjE,CAAC;IACJ,CAAC;IAbe,MAAA,eAAe,kBAa9B,CAAA;IAGD,SAAgB,cAAc,CAAC,KAAoC;QACjE,eAAe,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC;QACxC,WAAW,CAAC,EAAE,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,wCAAwC,CAAC,CAAC;IAC9F,CAAC;IAHe,MAAA,cAAc,iBAG7B,CAAA;AACH,CAAC,EA5DgB,KAAK,KAAL,KAAK,QA4DrB;AAED,MAAM,CAAC,MAAM,EACX,SAAS,EACT,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,cAAc,GACf,GAAG,KAAK,CAAC;AAEV,WAAW,CAAC,IAAI,GAAG,UAAU,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const en = {
|
|
2
|
+
errors: {
|
|
3
|
+
format: "%{attribute} %{message}",
|
|
4
|
+
messages: {
|
|
5
|
+
model_invalid: "Validation failed: %{errors}",
|
|
6
|
+
inclusion: "is not included in the list",
|
|
7
|
+
exclusion: "is reserved",
|
|
8
|
+
invalid: "is invalid",
|
|
9
|
+
confirmation: "doesn't match %{attribute}",
|
|
10
|
+
accepted: "must be accepted",
|
|
11
|
+
empty: "can't be empty",
|
|
12
|
+
blank: "can't be blank",
|
|
13
|
+
present: "must be blank",
|
|
14
|
+
too_long: {
|
|
15
|
+
one: "is too long (maximum is 1 character)",
|
|
16
|
+
other: "is too long (maximum is %{count} characters)",
|
|
17
|
+
},
|
|
18
|
+
password_too_long: "is too long",
|
|
19
|
+
too_short: {
|
|
20
|
+
one: "is too short (minimum is 1 character)",
|
|
21
|
+
other: "is too short (minimum is %{count} characters)",
|
|
22
|
+
},
|
|
23
|
+
wrong_length: {
|
|
24
|
+
one: "is the wrong length (should be 1 character)",
|
|
25
|
+
other: "is the wrong length (should be %{count} characters)",
|
|
26
|
+
},
|
|
27
|
+
not_a_number: "is not a number",
|
|
28
|
+
not_an_integer: "must be an integer",
|
|
29
|
+
greater_than: "must be greater than %{count}",
|
|
30
|
+
greater_than_or_equal_to: "must be greater than or equal to %{count}",
|
|
31
|
+
equal_to: "must be equal to %{count}",
|
|
32
|
+
less_than: "must be less than %{count}",
|
|
33
|
+
less_than_or_equal_to: "must be less than or equal to %{count}",
|
|
34
|
+
other_than: "must be other than %{count}",
|
|
35
|
+
in: "must be in %{count}",
|
|
36
|
+
odd: "must be odd",
|
|
37
|
+
even: "must be even",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=en.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"en.js","sourceRoot":"","sources":["../../lib/locale/en.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,EAAE,GAA4B;IACzC,MAAM,EAAE;QACN,MAAM,EAAE,yBAAyB;QAEjC,QAAQ,EAAE;YACR,aAAa,EAAE,8BAA8B;YAC7C,SAAS,EAAE,6BAA6B;YACxC,SAAS,EAAE,aAAa;YACxB,OAAO,EAAE,YAAY;YACrB,YAAY,EAAE,4BAA4B;YAC1C,QAAQ,EAAE,kBAAkB;YAC5B,KAAK,EAAE,gBAAgB;YACvB,KAAK,EAAE,gBAAgB;YACvB,OAAO,EAAE,eAAe;YACxB,QAAQ,EAAE;gBACR,GAAG,EAAE,sCAAsC;gBAC3C,KAAK,EAAE,8CAA8C;aACtD;YACD,iBAAiB,EAAE,aAAa;YAChC,SAAS,EAAE;gBACT,GAAG,EAAE,uCAAuC;gBAC5C,KAAK,EAAE,+CAA+C;aACvD;YACD,YAAY,EAAE;gBACZ,GAAG,EAAE,6CAA6C;gBAClD,KAAK,EAAE,qDAAqD;aAC7D;YACD,YAAY,EAAE,iBAAiB;YAC/B,cAAc,EAAE,oBAAoB;YACpC,YAAY,EAAE,+BAA+B;YAC7C,wBAAwB,EAAE,2CAA2C;YACrE,QAAQ,EAAE,2BAA2B;YACrC,SAAS,EAAE,4BAA4B;YACvC,qBAAqB,EAAE,wCAAwC;YAC/D,UAAU,EAAE,6BAA6B;YACzC,EAAE,EAAE,qBAAqB;YACzB,GAAG,EAAE,aAAa;YAClB,IAAI,EAAE,cAAc;SACrB;KACF;CACF,CAAC"}
|
package/dist/model.d.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { Errors } from "./errors.js";
|
|
2
|
+
import { ValidationContext, ClassMethods as ValidationsClassMethods } from "./validations.js";
|
|
3
|
+
import { HelperMethods } from "./validations/helper-methods.js";
|
|
4
|
+
import { Callbacks as ASCallbacks, included, type Included, type Extended } from "@blazetrails/activesupport";
|
|
5
|
+
import { type Hash } from "@blazetrails/ruby-compat";
|
|
6
|
+
import type { Translation } from "./translation.js";
|
|
7
|
+
import { ModelName } from "./naming.js";
|
|
8
|
+
import { defineModelCallbacks as defineModelCallbacksImpl } from "./callbacks.js";
|
|
9
|
+
import { EachValidator, Validator as ValidatorBase } from "./validator.js";
|
|
10
|
+
import type { ValidatableRecord } from "./validator.js";
|
|
11
|
+
import type { ConditionalOptions, ValidateArgs } from "./validations.js";
|
|
12
|
+
import * as Validates from "./validations/validates.js";
|
|
13
|
+
import { ClassMethods as WithClassMethods } from "./validations/with.js";
|
|
14
|
+
import type { ClassMethods as ConversionClassMethods } from "./conversion.js";
|
|
15
|
+
import { Access } from "./access.js";
|
|
16
|
+
import { Naming } from "./naming.js";
|
|
17
|
+
import { API } from "./api.js";
|
|
18
|
+
type ValidatorLike = ValidatorBase | EachValidator | {
|
|
19
|
+
validate(record: ValidatableRecord): void;
|
|
20
|
+
};
|
|
21
|
+
export interface Model extends API, Access, Naming {
|
|
22
|
+
runCallbacks(...args: Parameters<Included<typeof ASCallbacks>["runCallbacks"]>): ReturnType<Included<typeof ASCallbacks>["runCallbacks"]>;
|
|
23
|
+
freeze(): this;
|
|
24
|
+
/** @internal */
|
|
25
|
+
initializeDup(other: unknown): void;
|
|
26
|
+
}
|
|
27
|
+
export declare class Model {
|
|
28
|
+
/** @noRailsEquivalent CONVERGEABLE model-is-an-includable-concern */
|
|
29
|
+
static [included](base: {
|
|
30
|
+
new (...args: never[]): unknown;
|
|
31
|
+
prototype: object;
|
|
32
|
+
}): void;
|
|
33
|
+
static paramDelimiter: string;
|
|
34
|
+
private static _modelName;
|
|
35
|
+
static _validators: Hash<string | null, Array<ValidatorLike>>;
|
|
36
|
+
static _isValidators: boolean;
|
|
37
|
+
static _toPartialPath: Extended<typeof ConversionClassMethods>["_toPartialPath"];
|
|
38
|
+
static validates: Extended<typeof Validates>["validates"];
|
|
39
|
+
static validatesBang: Extended<typeof Validates>["validatesBang"];
|
|
40
|
+
static clearValidatorsBang: Extended<typeof ValidationsClassMethods>["clearValidatorsBang"];
|
|
41
|
+
static isAttributeMethod: Extended<typeof ValidationsClassMethods>["isAttributeMethod"];
|
|
42
|
+
static validate: <T extends ValidatableRecord = ValidatableRecord>(...args: ValidateArgs<T>) => void;
|
|
43
|
+
static validatesEach: <T extends ValidatableRecord = ValidatableRecord>(attrNames: Array<string | string[]>, block: (record: T, attribute: string, value: unknown) => void, options?: ConditionalOptions) => void;
|
|
44
|
+
static validatesWith: Extended<typeof WithClassMethods>["validatesWith"];
|
|
45
|
+
static validators: Extended<typeof ValidationsClassMethods>["validators"];
|
|
46
|
+
static validatorsOn: Extended<typeof ValidationsClassMethods>["validatorsOn"];
|
|
47
|
+
static validatesPresenceOf: Extended<typeof HelperMethods>["validatesPresenceOf"];
|
|
48
|
+
static validatesAbsenceOf: Extended<typeof HelperMethods>["validatesAbsenceOf"];
|
|
49
|
+
static validatesLengthOf: Extended<typeof HelperMethods>["validatesLengthOf"];
|
|
50
|
+
static validatesSizeOf: Extended<typeof HelperMethods>["validatesSizeOf"];
|
|
51
|
+
static validatesNumericalityOf: Extended<typeof HelperMethods>["validatesNumericalityOf"];
|
|
52
|
+
static validatesInclusionOf: Extended<typeof HelperMethods>["validatesInclusionOf"];
|
|
53
|
+
static validatesExclusionOf: Extended<typeof HelperMethods>["validatesExclusionOf"];
|
|
54
|
+
static validatesFormatOf: Extended<typeof HelperMethods>["validatesFormatOf"];
|
|
55
|
+
static validatesAcceptanceOf: Extended<typeof HelperMethods>["validatesAcceptanceOf"];
|
|
56
|
+
static validatesConfirmationOf: Extended<typeof HelperMethods>["validatesConfirmationOf"];
|
|
57
|
+
static validatesComparisonOf: Extended<typeof HelperMethods>["validatesComparisonOf"];
|
|
58
|
+
/** @internal */
|
|
59
|
+
static _mergeAttributes: Extended<typeof HelperMethods>["_mergeAttributes"];
|
|
60
|
+
static setCallback: Extended<typeof ASCallbacks.ClassMethods>["setCallback"];
|
|
61
|
+
static skipCallback: Extended<typeof ASCallbacks.ClassMethods>["skipCallback"];
|
|
62
|
+
static resetCallbacks: Extended<typeof ASCallbacks.ClassMethods>["resetCallbacks"];
|
|
63
|
+
static defineModelCallbacks: typeof defineModelCallbacksImpl;
|
|
64
|
+
static humanAttributeName: Translation["humanAttributeName"];
|
|
65
|
+
static i18nScope: string;
|
|
66
|
+
static lookupAncestors: () => Array<{
|
|
67
|
+
new (...args: never[]): unknown;
|
|
68
|
+
modelName: ModelName;
|
|
69
|
+
}>;
|
|
70
|
+
static modelName: ModelName;
|
|
71
|
+
/** @internal */
|
|
72
|
+
_errors?: Errors<this>;
|
|
73
|
+
errors: Errors<this>;
|
|
74
|
+
/** @internal */
|
|
75
|
+
static predicateForValidationContext: Extended<typeof ValidationsClassMethods>["predicateForValidationContext"];
|
|
76
|
+
/** @internal */
|
|
77
|
+
static _validatesDefaultKeys: Extended<typeof Validates>["_validatesDefaultKeys"];
|
|
78
|
+
/** @internal */
|
|
79
|
+
static _parseValidatesOptions: Extended<typeof Validates>["_parseValidatesOptions"];
|
|
80
|
+
/**
|
|
81
|
+
* @inventedArm if — PERMANENT
|
|
82
|
+
* @inlinedFrom ActiveModel::Attributes#initialize rails/v8.0.5.2/activemodel/lib/active_model/attributes.rb:106-109
|
|
83
|
+
*/
|
|
84
|
+
constructor(attributes?: Record<string, unknown> | Map<string, unknown> | null);
|
|
85
|
+
/** @internal */
|
|
86
|
+
_contextForValidation?: ValidationContext;
|
|
87
|
+
dup(): this;
|
|
88
|
+
}
|
|
89
|
+
export {};
|
|
90
|
+
//# sourceMappingURL=model.d.ts.map
|
package/dist/model.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { include, included, runLoadHooks, ToJsonWithActiveSupportEncoder, } from "@blazetrails/activesupport";
|
|
2
|
+
import { isModuleIncluded, methodCacheSerial, rbObjDup } from "@blazetrails/ruby-compat";
|
|
3
|
+
import { Access } from "./access.js";
|
|
4
|
+
import { API } from "./api.js";
|
|
5
|
+
import { Attributes } from "./attributes.js";
|
|
6
|
+
/** @perf 100ns — PERMANENT */
|
|
7
|
+
const _includesAttributesCache = new WeakMap();
|
|
8
|
+
/** @perf 100ns — PERMANENT */
|
|
9
|
+
function _includesAttributes(klass) {
|
|
10
|
+
const hit = _includesAttributesCache.get(klass);
|
|
11
|
+
if (hit && hit.serial === methodCacheSerial)
|
|
12
|
+
return hit.value;
|
|
13
|
+
const serial = methodCacheSerial;
|
|
14
|
+
const value = isModuleIncluded(klass, Attributes);
|
|
15
|
+
_includesAttributesCache.set(klass, { serial, value });
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
|
|
19
|
+
export class Model {
|
|
20
|
+
/** @noRailsEquivalent CONVERGEABLE model-is-an-includable-concern */
|
|
21
|
+
static [included](base) {
|
|
22
|
+
include(base, API);
|
|
23
|
+
include(base, Access);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* @inventedArm if — PERMANENT
|
|
27
|
+
* @inlinedFrom ActiveModel::Attributes#initialize rails/v8.0.5.2/activemodel/lib/active_model/attributes.rb:106-109
|
|
28
|
+
*/
|
|
29
|
+
constructor(attributes = {}) {
|
|
30
|
+
const klass = new.target;
|
|
31
|
+
if (_includesAttributes(klass)) {
|
|
32
|
+
Reflect.set(this, "_attributes", klass._defaultAttributes().deepDup());
|
|
33
|
+
}
|
|
34
|
+
if (attributes != null)
|
|
35
|
+
this.assignAttributes(attributes);
|
|
36
|
+
}
|
|
37
|
+
/** @internal */
|
|
38
|
+
_contextForValidation;
|
|
39
|
+
dup() {
|
|
40
|
+
return rbObjDup(this);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
include(Model, API);
|
|
44
|
+
include(Model, ToJsonWithActiveSupportEncoder);
|
|
45
|
+
include(Model, Access);
|
|
46
|
+
runLoadHooks("active_model", Model);
|
|
47
|
+
//# sourceMappingURL=model.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../lib/model.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,OAAO,EACP,QAAQ,EACR,YAAY,EACZ,8BAA8B,GAG/B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,QAAQ,EAAa,MAAM,0BAA0B,CAAC;AAUpG,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAgB7C,8BAA8B;AAC9B,MAAM,wBAAwB,GAAG,IAAI,OAAO,EAA8C,CAAC;AAE3F,8BAA8B;AAC9B,SAAS,mBAAmB,CAAC,KAE5B;IACC,MAAM,GAAG,GAAG,wBAAwB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAChD,IAAI,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,iBAAiB;QAAE,OAAO,GAAG,CAAC,KAAK,CAAC;IAC9D,MAAM,MAAM,GAAG,iBAAiB,CAAC;IACjC,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;IAClD,wBAAwB,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IACvD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,4EAA4E;AAC5E,MAAM,OAAO,KAAK;IAChB,qEAAqE;IACrE,MAAM,CAAC,CAAC,QAAQ,CAAC,CAAC,IAA4D;QAC5E,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;QACnB,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACxB,CAAC;IAmFD;;;OAGG;IACH,YAAY,UAAU,GAA0D,EAAE;QAChF,MAAM,KAAK,GAAG,IAAI,MAAM,CAAC;QACzB,IAAI,mBAAmB,CAAC,KAAK,CAAC,EAAE,CAAC;YAC/B,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,CAAC,kBAAkB,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,IAAI,UAAU,IAAI,IAAI;YAAE,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;IAC5D,CAAC;IAED,gBAAgB;IAChB,qBAAqB,CAAqB;IAE1C,GAAG;QACD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACF;AAED,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAEpB,OAAO,CAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC;AAE/C,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;AAEvB,YAAY,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { Autoload, type Extended } from "@blazetrails/activesupport";
|
|
2
|
+
import type { Attribute } from "./attribute.js";
|
|
3
|
+
import type { Error } from "./error.js";
|
|
4
|
+
import type { Errors, RangeError, StrictValidationFailed, UnknownAttributeError } from "./errors.js";
|
|
5
|
+
import type { NestedError } from "./nested-error.js";
|
|
6
|
+
import type { JSON } from "./serializers/json.js";
|
|
7
|
+
import type { ValidationError, Validations } from "./validations.js";
|
|
8
|
+
type AutoloadModule = Autoload.Autoload & Extended<typeof Autoload>;
|
|
9
|
+
export declare const ActiveModel: AutoloadModule & {
|
|
10
|
+
Attribute: typeof Attribute;
|
|
11
|
+
Errors: typeof Errors;
|
|
12
|
+
Error: typeof Error;
|
|
13
|
+
NestedError: typeof NestedError;
|
|
14
|
+
RangeError: typeof RangeError;
|
|
15
|
+
StrictValidationFailed: typeof StrictValidationFailed;
|
|
16
|
+
UnknownAttributeError: typeof UnknownAttributeError;
|
|
17
|
+
ValidationError: typeof ValidationError;
|
|
18
|
+
Validations: typeof Validations;
|
|
19
|
+
Serializers: typeof Serializers;
|
|
20
|
+
Type: typeof import("./type.js");
|
|
21
|
+
Lint: typeof import("./lint.js");
|
|
22
|
+
};
|
|
23
|
+
export declare const Serializers: AutoloadModule & {
|
|
24
|
+
JSON: typeof JSON;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
27
|
+
//# sourceMappingURL=namespaces.d.ts.map
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Autoload, extend } from "@blazetrails/activesupport";
|
|
2
|
+
import { TopLevel, constSet } from "@blazetrails/ruby-compat";
|
|
3
|
+
const loadPath = {
|
|
4
|
+
"active_model/attribute": () => import("./attribute.js"),
|
|
5
|
+
"active_model/errors": () => import("./errors.js"),
|
|
6
|
+
"active_model/error": () => import("./error.js"),
|
|
7
|
+
"active_model/validations": () => import("./validations.js"),
|
|
8
|
+
"active_model/serializers/json": () => import("./serializers/json.js"),
|
|
9
|
+
};
|
|
10
|
+
export const ActiveModel = { name: "ActiveModel", loadPath };
|
|
11
|
+
constSet(TopLevel, "ActiveModel", ActiveModel);
|
|
12
|
+
extend(ActiveModel, Autoload);
|
|
13
|
+
ActiveModel.autoload("Attribute");
|
|
14
|
+
ActiveModel.autoload("Validations");
|
|
15
|
+
ActiveModel.eagerAutoload(() => {
|
|
16
|
+
ActiveModel.autoload("Errors");
|
|
17
|
+
ActiveModel.autoload("Error");
|
|
18
|
+
ActiveModel.autoload("RangeError", "active_model/errors");
|
|
19
|
+
ActiveModel.autoload("StrictValidationFailed", "active_model/errors");
|
|
20
|
+
ActiveModel.autoload("UnknownAttributeError", "active_model/errors");
|
|
21
|
+
ActiveModel.autoload("ValidationError", "active_model/validations");
|
|
22
|
+
});
|
|
23
|
+
export const Serializers = { name: "ActiveModel::Serializers", loadPath };
|
|
24
|
+
extend(Serializers, Autoload);
|
|
25
|
+
Serializers.eagerAutoload(() => {
|
|
26
|
+
Serializers.autoload("JSON");
|
|
27
|
+
});
|
|
28
|
+
ActiveModel.Serializers = Serializers;
|
|
29
|
+
Object.defineProperty(ActiveModel, "eagerLoadBang", {
|
|
30
|
+
value: async function eagerLoadBang() {
|
|
31
|
+
await Autoload.eagerLoadBang.call(this);
|
|
32
|
+
await Serializers.eagerLoadBang();
|
|
33
|
+
},
|
|
34
|
+
writable: true,
|
|
35
|
+
configurable: true,
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=namespaces.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"namespaces.js","sourceRoot":"","sources":["../lib/namespaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAiB,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAe9D,MAAM,QAAQ,GAA2C;IACvD,wBAAwB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC;IACxD,qBAAqB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC;IAClD,oBAAoB,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC;IAChD,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EAAE,KAAK,UAAU,aAAa;QACjC,MAAM,QAAQ,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACxC,MAAM,WAAW,CAAC,aAAa,EAAE,CAAC;IACpC,CAAC;IACD,QAAQ,EAAE,IAAI;IACd,YAAY,EAAE,IAAI;CACnB,CAAC,CAAC"}
|
package/dist/naming.d.ts
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ToJsonWithActiveSupportEncoder, extended } from "@blazetrails/activesupport";
|
|
2
|
+
import { classModule } from "@blazetrails/ruby-compat";
|
|
3
|
+
type RecordOrClass = ModelName | {
|
|
4
|
+
modelName: ModelName;
|
|
5
|
+
} | {
|
|
6
|
+
toModel: () => unknown;
|
|
7
|
+
} | {
|
|
8
|
+
constructor: {
|
|
9
|
+
modelName: ModelName;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
interface NamingHost {
|
|
13
|
+
prototype: object;
|
|
14
|
+
_modelName?: ModelName | null;
|
|
15
|
+
}
|
|
16
|
+
export declare class Naming {
|
|
17
|
+
/** @noRailsEquivalent PERMANENT */
|
|
18
|
+
static readonly [classModule] = true;
|
|
19
|
+
static [extended](base: NamingHost): void;
|
|
20
|
+
get modelName(): ModelName;
|
|
21
|
+
/** @internal */
|
|
22
|
+
private static modelNameFromRecordOrClass;
|
|
23
|
+
static plural(recordOrClass: RecordOrClass): string;
|
|
24
|
+
static singular(recordOrClass: RecordOrClass): string;
|
|
25
|
+
static isUncountable(recordOrClass: RecordOrClass): boolean;
|
|
26
|
+
static singularRouteKey(recordOrClass: RecordOrClass): string;
|
|
27
|
+
static routeKey(recordOrClass: RecordOrClass): string;
|
|
28
|
+
static paramKey(recordOrClass: RecordOrClass): string;
|
|
29
|
+
}
|
|
30
|
+
import type { TranslateOptions } from "@blazetrails/i18n";
|
|
31
|
+
export interface ModelLike {
|
|
32
|
+
readonly name: string;
|
|
33
|
+
i18nScope?: string;
|
|
34
|
+
lookupAncestors?: () => Array<ModelLike & {
|
|
35
|
+
modelName: ModelName;
|
|
36
|
+
}>;
|
|
37
|
+
modelName?: ModelName;
|
|
38
|
+
}
|
|
39
|
+
export interface ModelName extends ToJsonWithActiveSupportEncoder {
|
|
40
|
+
}
|
|
41
|
+
export declare class ModelName {
|
|
42
|
+
name: string;
|
|
43
|
+
singular: string;
|
|
44
|
+
plural: string;
|
|
45
|
+
element: string;
|
|
46
|
+
collection: string;
|
|
47
|
+
paramKey: string;
|
|
48
|
+
routeKey: string;
|
|
49
|
+
singularRouteKey: string;
|
|
50
|
+
i18nKey: string;
|
|
51
|
+
isUncountable: boolean;
|
|
52
|
+
private _human;
|
|
53
|
+
private _klass;
|
|
54
|
+
private _unnamespaced?;
|
|
55
|
+
get cacheKey(): string;
|
|
56
|
+
equals(other: unknown): boolean;
|
|
57
|
+
caseEquals(other: unknown): boolean;
|
|
58
|
+
compare(other: unknown): number | undefined;
|
|
59
|
+
matchOperator(pattern: unknown): unknown;
|
|
60
|
+
notMatchOperator(pattern: unknown): boolean;
|
|
61
|
+
eql(other: unknown): boolean;
|
|
62
|
+
match(pattern: unknown): boolean;
|
|
63
|
+
toString(): string;
|
|
64
|
+
asJson(_options?: unknown): string;
|
|
65
|
+
constructor(klass: ModelLike, namespace?: object | null, name?: string | null, locale?: string);
|
|
66
|
+
human(options?: TranslateOptions): string;
|
|
67
|
+
/** @internal */
|
|
68
|
+
_singularize(string: string): string;
|
|
69
|
+
/** @internal */
|
|
70
|
+
i18nKeys(): string[];
|
|
71
|
+
/** @internal */
|
|
72
|
+
private i18nScope;
|
|
73
|
+
private _cachedI18nKeys?;
|
|
74
|
+
}
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=naming.d.ts.map
|