@atscript/core 0.1.14 → 0.1.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +25 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +25 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -443,8 +443,8 @@ var SemanticPrimitiveNode = class SemanticPrimitiveNode extends SemanticNode {
|
|
|
443
443
|
});
|
|
444
444
|
}
|
|
445
445
|
if (this.type === "string") {
|
|
446
|
-
if (this.config.expect?.
|
|
447
|
-
name: "
|
|
446
|
+
if (this.config.expect?.required === true) this.annotations.push({
|
|
447
|
+
name: "meta.required",
|
|
448
448
|
token: dummyToken,
|
|
449
449
|
args: []
|
|
450
450
|
});
|
|
@@ -478,6 +478,13 @@ var SemanticPrimitiveNode = class SemanticPrimitiveNode extends SemanticNode {
|
|
|
478
478
|
args: []
|
|
479
479
|
});
|
|
480
480
|
}
|
|
481
|
+
if (this.type === "boolean") {
|
|
482
|
+
if (this.config.expect?.required === true) this.annotations.push({
|
|
483
|
+
name: "meta.required",
|
|
484
|
+
token: dummyToken,
|
|
485
|
+
args: []
|
|
486
|
+
});
|
|
487
|
+
}
|
|
481
488
|
}
|
|
482
489
|
get key() {
|
|
483
490
|
return this.parentKey ? `${this.parentKey}.${this._id}` : this._id;
|
|
@@ -3078,6 +3085,16 @@ const metaAnnotations = {
|
|
|
3078
3085
|
nodeType: ["prop"],
|
|
3079
3086
|
multiple: false
|
|
3080
3087
|
}),
|
|
3088
|
+
required: new AnnotationSpec({
|
|
3089
|
+
description: "Marks a field as required for form validation. For strings: must contain at least one non-whitespace character. For booleans: must be true.\n\n**Example:**```atscript@meta.requiredname: string\n@meta.required \"You must accept the terms\"agreed: boolean```",
|
|
3090
|
+
defType: ["string", "boolean"],
|
|
3091
|
+
argument: [{
|
|
3092
|
+
name: "message",
|
|
3093
|
+
optional: true,
|
|
3094
|
+
type: "string",
|
|
3095
|
+
description: "Optional error message to display if the validation fails."
|
|
3096
|
+
}]
|
|
3097
|
+
}),
|
|
3081
3098
|
isKey: new AnnotationSpec({
|
|
3082
3099
|
description: "Marks a **key field** inside an array. This annotation is used to identify unique fields within an array that can be used as **lookup keys**.\n\n\n\n**Example:**\n```atscript\nexport interface User {\n id: string\n profiles: {\n @meta.isKey\n profileId: string\n name: string\n }[]\n}\n```\n",
|
|
3083
3100
|
nodeType: ["prop"],
|
|
@@ -3168,9 +3185,9 @@ const primitives = {
|
|
|
3168
3185
|
message: "Invalid UUID format."
|
|
3169
3186
|
}
|
|
3170
3187
|
},
|
|
3171
|
-
|
|
3188
|
+
required: {
|
|
3172
3189
|
documentation: "Non-empty string that contains at least one non-whitespace character.",
|
|
3173
|
-
expect: {
|
|
3190
|
+
expect: { required: true }
|
|
3174
3191
|
}
|
|
3175
3192
|
}
|
|
3176
3193
|
},
|
|
@@ -3202,6 +3219,10 @@ const primitives = {
|
|
|
3202
3219
|
type: "boolean",
|
|
3203
3220
|
documentation: "Represents true/false values.",
|
|
3204
3221
|
extensions: {
|
|
3222
|
+
required: {
|
|
3223
|
+
documentation: "Boolean that must be true. Useful for checkboxes like \"accept terms\".",
|
|
3224
|
+
expect: { required: true }
|
|
3225
|
+
},
|
|
3205
3226
|
true: { documentation: "Represents a true value." },
|
|
3206
3227
|
false: { documentation: "Represents a false value." }
|
|
3207
3228
|
}
|
|
@@ -3287,16 +3308,6 @@ const expectAnnotations = {
|
|
|
3287
3308
|
description: "Validates that a number is an integer (no decimal places).\n\n**Example:**```atscript@expect.intage: number```",
|
|
3288
3309
|
defType: ["number"]
|
|
3289
3310
|
}),
|
|
3290
|
-
filled: new AnnotationSpec({
|
|
3291
|
-
description: "Validates that a string is not empty and contains at least one non-whitespace character.\n\n**Example:**```atscript@expect.filledname: string```",
|
|
3292
|
-
defType: ["string"],
|
|
3293
|
-
argument: [{
|
|
3294
|
-
name: "message",
|
|
3295
|
-
optional: true,
|
|
3296
|
-
type: "string",
|
|
3297
|
-
description: "Optional error message to display if the validation fails."
|
|
3298
|
-
}]
|
|
3299
|
-
}),
|
|
3300
3311
|
pattern: new AnnotationSpec({
|
|
3301
3312
|
description: "Validates that a string matches a specific pattern.\n\n**Example:**```atscript@expect.pattern \"[a-z]+\", \"u\"name: string```",
|
|
3302
3313
|
defType: ["string"],
|
package/dist/index.d.ts
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -419,8 +419,8 @@ var SemanticPrimitiveNode = class SemanticPrimitiveNode extends SemanticNode {
|
|
|
419
419
|
});
|
|
420
420
|
}
|
|
421
421
|
if (this.type === "string") {
|
|
422
|
-
if (this.config.expect?.
|
|
423
|
-
name: "
|
|
422
|
+
if (this.config.expect?.required === true) this.annotations.push({
|
|
423
|
+
name: "meta.required",
|
|
424
424
|
token: dummyToken,
|
|
425
425
|
args: []
|
|
426
426
|
});
|
|
@@ -454,6 +454,13 @@ var SemanticPrimitiveNode = class SemanticPrimitiveNode extends SemanticNode {
|
|
|
454
454
|
args: []
|
|
455
455
|
});
|
|
456
456
|
}
|
|
457
|
+
if (this.type === "boolean") {
|
|
458
|
+
if (this.config.expect?.required === true) this.annotations.push({
|
|
459
|
+
name: "meta.required",
|
|
460
|
+
token: dummyToken,
|
|
461
|
+
args: []
|
|
462
|
+
});
|
|
463
|
+
}
|
|
457
464
|
}
|
|
458
465
|
get key() {
|
|
459
466
|
return this.parentKey ? `${this.parentKey}.${this._id}` : this._id;
|
|
@@ -3054,6 +3061,16 @@ const metaAnnotations = {
|
|
|
3054
3061
|
nodeType: ["prop"],
|
|
3055
3062
|
multiple: false
|
|
3056
3063
|
}),
|
|
3064
|
+
required: new AnnotationSpec({
|
|
3065
|
+
description: "Marks a field as required for form validation. For strings: must contain at least one non-whitespace character. For booleans: must be true.\n\n**Example:**```atscript@meta.requiredname: string\n@meta.required \"You must accept the terms\"agreed: boolean```",
|
|
3066
|
+
defType: ["string", "boolean"],
|
|
3067
|
+
argument: [{
|
|
3068
|
+
name: "message",
|
|
3069
|
+
optional: true,
|
|
3070
|
+
type: "string",
|
|
3071
|
+
description: "Optional error message to display if the validation fails."
|
|
3072
|
+
}]
|
|
3073
|
+
}),
|
|
3057
3074
|
isKey: new AnnotationSpec({
|
|
3058
3075
|
description: "Marks a **key field** inside an array. This annotation is used to identify unique fields within an array that can be used as **lookup keys**.\n\n\n\n**Example:**\n```atscript\nexport interface User {\n id: string\n profiles: {\n @meta.isKey\n profileId: string\n name: string\n }[]\n}\n```\n",
|
|
3059
3076
|
nodeType: ["prop"],
|
|
@@ -3144,9 +3161,9 @@ const primitives = {
|
|
|
3144
3161
|
message: "Invalid UUID format."
|
|
3145
3162
|
}
|
|
3146
3163
|
},
|
|
3147
|
-
|
|
3164
|
+
required: {
|
|
3148
3165
|
documentation: "Non-empty string that contains at least one non-whitespace character.",
|
|
3149
|
-
expect: {
|
|
3166
|
+
expect: { required: true }
|
|
3150
3167
|
}
|
|
3151
3168
|
}
|
|
3152
3169
|
},
|
|
@@ -3178,6 +3195,10 @@ const primitives = {
|
|
|
3178
3195
|
type: "boolean",
|
|
3179
3196
|
documentation: "Represents true/false values.",
|
|
3180
3197
|
extensions: {
|
|
3198
|
+
required: {
|
|
3199
|
+
documentation: "Boolean that must be true. Useful for checkboxes like \"accept terms\".",
|
|
3200
|
+
expect: { required: true }
|
|
3201
|
+
},
|
|
3181
3202
|
true: { documentation: "Represents a true value." },
|
|
3182
3203
|
false: { documentation: "Represents a false value." }
|
|
3183
3204
|
}
|
|
@@ -3263,16 +3284,6 @@ const expectAnnotations = {
|
|
|
3263
3284
|
description: "Validates that a number is an integer (no decimal places).\n\n**Example:**```atscript@expect.intage: number```",
|
|
3264
3285
|
defType: ["number"]
|
|
3265
3286
|
}),
|
|
3266
|
-
filled: new AnnotationSpec({
|
|
3267
|
-
description: "Validates that a string is not empty and contains at least one non-whitespace character.\n\n**Example:**```atscript@expect.filledname: string```",
|
|
3268
|
-
defType: ["string"],
|
|
3269
|
-
argument: [{
|
|
3270
|
-
name: "message",
|
|
3271
|
-
optional: true,
|
|
3272
|
-
type: "string",
|
|
3273
|
-
description: "Optional error message to display if the validation fails."
|
|
3274
|
-
}]
|
|
3275
|
-
}),
|
|
3276
3287
|
pattern: new AnnotationSpec({
|
|
3277
3288
|
description: "Validates that a string matches a specific pattern.\n\n**Example:**```atscript@expect.pattern \"[a-z]+\", \"u\"name: string```",
|
|
3278
3289
|
defType: ["string"],
|