@atscript/core 0.1.14 → 0.1.16
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 +27 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +27 -15
- 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;
|
|
@@ -857,7 +864,8 @@ var AnnotationSpec = class {
|
|
|
857
864
|
message: `Multiple "${mainToken.text}" annotations are not allowed.`,
|
|
858
865
|
range: mainToken.range
|
|
859
866
|
});
|
|
860
|
-
|
|
867
|
+
const effectiveEntity = mainToken.parentNode.entity === "ref" && this.config.nodeType?.includes("prop") ? "prop" : mainToken.parentNode.entity;
|
|
868
|
+
if (this.config.nodeType && this.config.nodeType.length > 0 && !this.config.nodeType.includes(effectiveEntity)) messages.push({
|
|
861
869
|
severity: 1,
|
|
862
870
|
message: `${mainToken.text} applies only to ${this.config.nodeType.join(", ")} nodes.`,
|
|
863
871
|
range: mainToken.range
|
|
@@ -3078,6 +3086,16 @@ const metaAnnotations = {
|
|
|
3078
3086
|
nodeType: ["prop"],
|
|
3079
3087
|
multiple: false
|
|
3080
3088
|
}),
|
|
3089
|
+
required: new AnnotationSpec({
|
|
3090
|
+
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```",
|
|
3091
|
+
defType: ["string", "boolean"],
|
|
3092
|
+
argument: [{
|
|
3093
|
+
name: "message",
|
|
3094
|
+
optional: true,
|
|
3095
|
+
type: "string",
|
|
3096
|
+
description: "Optional error message to display if the validation fails."
|
|
3097
|
+
}]
|
|
3098
|
+
}),
|
|
3081
3099
|
isKey: new AnnotationSpec({
|
|
3082
3100
|
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
3101
|
nodeType: ["prop"],
|
|
@@ -3168,9 +3186,9 @@ const primitives = {
|
|
|
3168
3186
|
message: "Invalid UUID format."
|
|
3169
3187
|
}
|
|
3170
3188
|
},
|
|
3171
|
-
|
|
3189
|
+
required: {
|
|
3172
3190
|
documentation: "Non-empty string that contains at least one non-whitespace character.",
|
|
3173
|
-
expect: {
|
|
3191
|
+
expect: { required: true }
|
|
3174
3192
|
}
|
|
3175
3193
|
}
|
|
3176
3194
|
},
|
|
@@ -3202,6 +3220,10 @@ const primitives = {
|
|
|
3202
3220
|
type: "boolean",
|
|
3203
3221
|
documentation: "Represents true/false values.",
|
|
3204
3222
|
extensions: {
|
|
3223
|
+
required: {
|
|
3224
|
+
documentation: "Boolean that must be true. Useful for checkboxes like \"accept terms\".",
|
|
3225
|
+
expect: { required: true }
|
|
3226
|
+
},
|
|
3205
3227
|
true: { documentation: "Represents a true value." },
|
|
3206
3228
|
false: { documentation: "Represents a false value." }
|
|
3207
3229
|
}
|
|
@@ -3287,16 +3309,6 @@ const expectAnnotations = {
|
|
|
3287
3309
|
description: "Validates that a number is an integer (no decimal places).\n\n**Example:**```atscript@expect.intage: number```",
|
|
3288
3310
|
defType: ["number"]
|
|
3289
3311
|
}),
|
|
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
3312
|
pattern: new AnnotationSpec({
|
|
3301
3313
|
description: "Validates that a string matches a specific pattern.\n\n**Example:**```atscript@expect.pattern \"[a-z]+\", \"u\"name: string```",
|
|
3302
3314
|
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;
|
|
@@ -833,7 +840,8 @@ var AnnotationSpec = class {
|
|
|
833
840
|
message: `Multiple "${mainToken.text}" annotations are not allowed.`,
|
|
834
841
|
range: mainToken.range
|
|
835
842
|
});
|
|
836
|
-
|
|
843
|
+
const effectiveEntity = mainToken.parentNode.entity === "ref" && this.config.nodeType?.includes("prop") ? "prop" : mainToken.parentNode.entity;
|
|
844
|
+
if (this.config.nodeType && this.config.nodeType.length > 0 && !this.config.nodeType.includes(effectiveEntity)) messages.push({
|
|
837
845
|
severity: 1,
|
|
838
846
|
message: `${mainToken.text} applies only to ${this.config.nodeType.join(", ")} nodes.`,
|
|
839
847
|
range: mainToken.range
|
|
@@ -3054,6 +3062,16 @@ const metaAnnotations = {
|
|
|
3054
3062
|
nodeType: ["prop"],
|
|
3055
3063
|
multiple: false
|
|
3056
3064
|
}),
|
|
3065
|
+
required: new AnnotationSpec({
|
|
3066
|
+
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```",
|
|
3067
|
+
defType: ["string", "boolean"],
|
|
3068
|
+
argument: [{
|
|
3069
|
+
name: "message",
|
|
3070
|
+
optional: true,
|
|
3071
|
+
type: "string",
|
|
3072
|
+
description: "Optional error message to display if the validation fails."
|
|
3073
|
+
}]
|
|
3074
|
+
}),
|
|
3057
3075
|
isKey: new AnnotationSpec({
|
|
3058
3076
|
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
3077
|
nodeType: ["prop"],
|
|
@@ -3144,9 +3162,9 @@ const primitives = {
|
|
|
3144
3162
|
message: "Invalid UUID format."
|
|
3145
3163
|
}
|
|
3146
3164
|
},
|
|
3147
|
-
|
|
3165
|
+
required: {
|
|
3148
3166
|
documentation: "Non-empty string that contains at least one non-whitespace character.",
|
|
3149
|
-
expect: {
|
|
3167
|
+
expect: { required: true }
|
|
3150
3168
|
}
|
|
3151
3169
|
}
|
|
3152
3170
|
},
|
|
@@ -3178,6 +3196,10 @@ const primitives = {
|
|
|
3178
3196
|
type: "boolean",
|
|
3179
3197
|
documentation: "Represents true/false values.",
|
|
3180
3198
|
extensions: {
|
|
3199
|
+
required: {
|
|
3200
|
+
documentation: "Boolean that must be true. Useful for checkboxes like \"accept terms\".",
|
|
3201
|
+
expect: { required: true }
|
|
3202
|
+
},
|
|
3181
3203
|
true: { documentation: "Represents a true value." },
|
|
3182
3204
|
false: { documentation: "Represents a false value." }
|
|
3183
3205
|
}
|
|
@@ -3263,16 +3285,6 @@ const expectAnnotations = {
|
|
|
3263
3285
|
description: "Validates that a number is an integer (no decimal places).\n\n**Example:**```atscript@expect.intage: number```",
|
|
3264
3286
|
defType: ["number"]
|
|
3265
3287
|
}),
|
|
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
3288
|
pattern: new AnnotationSpec({
|
|
3277
3289
|
description: "Validates that a string matches a specific pattern.\n\n**Example:**```atscript@expect.pattern \"[a-z]+\", \"u\"name: string```",
|
|
3278
3290
|
defType: ["string"],
|