@botpress/cli 5.0.1 → 5.0.3
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/.turbo/turbo-build.log +12 -12
- package/dist/command-implementations/lint-command.js +6 -3
- package/dist/command-implementations/lint-command.js.map +2 -2
- package/dist/linter/base-linter.d.ts +1 -1
- package/dist/linter/base-linter.js +21 -1
- package/dist/linter/base-linter.js.map +2 -2
- package/dist/linter/bot-linter.d.ts +2 -1
- package/dist/linter/bot-linter.js +2 -2
- package/dist/linter/bot-linter.js.map +2 -2
- package/dist/linter/integration-linter.d.ts +2 -1
- package/dist/linter/integration-linter.js +2 -2
- package/dist/linter/integration-linter.js.map +2 -2
- package/dist/linter/interface-linter.d.ts +2 -1
- package/dist/linter/interface-linter.js +2 -2
- package/dist/linter/interface-linter.js.map +2 -2
- package/dist/linter/ruleset-tests/bot.ruleset.test.js +322 -0
- package/dist/linter/ruleset-tests/bot.ruleset.test.js.map +2 -2
- package/dist/linter/ruleset-tests/integration.ruleset.test.js +713 -0
- package/dist/linter/ruleset-tests/integration.ruleset.test.js.map +2 -2
- package/dist/linter/ruleset-tests/interface.ruleset.test.js +502 -0
- package/dist/linter/ruleset-tests/interface.ruleset.test.js.map +2 -2
- package/dist/linter/rulesets/bot.ruleset.d.ts +12 -36
- package/dist/linter/rulesets/bot.ruleset.js +24 -6
- package/dist/linter/rulesets/bot.ruleset.js.map +2 -2
- package/dist/linter/rulesets/integration.ruleset.d.ts +27 -81
- package/dist/linter/rulesets/integration.ruleset.js +48 -16
- package/dist/linter/rulesets/integration.ruleset.js.map +2 -2
- package/dist/linter/rulesets/interface.ruleset.d.ts +10 -30
- package/dist/linter/rulesets/interface.ruleset.js +32 -8
- package/dist/linter/rulesets/interface.ruleset.js.map +2 -2
- package/dist/linter/spectral-functions.d.ts +25 -5
- package/dist/linter/spectral-functions.js +107 -6
- package/dist/linter/spectral-functions.js.map +2 -2
- package/dist/utils/file-watcher.d.ts +1 -1
- package/dist/utils/file-watcher.js +2 -2
- package/dist/utils/file-watcher.js.map +3 -3
- package/package.json +5 -3
- package/templates/empty-bot/package.json +2 -2
- package/templates/empty-integration/package.json +2 -2
- package/templates/empty-plugin/package.json +1 -1
- package/templates/hello-world/package.json +2 -2
- package/templates/webhook-message/package.json +2 -2
|
@@ -8,9 +8,7 @@ export declare const INTERFACE_RULESET: {
|
|
|
8
8
|
given: string;
|
|
9
9
|
then: {
|
|
10
10
|
field: string;
|
|
11
|
-
function: (
|
|
12
|
-
message: string;
|
|
13
|
-
}[];
|
|
11
|
+
function: import("@stoplight/spectral-core").RulesetFunction<any, any> | import("@stoplight/spectral-core").RulesetFunctionWithValidator<any, any>;
|
|
14
12
|
}[];
|
|
15
13
|
};
|
|
16
14
|
'action-inputparams-must-have-a-description': {
|
|
@@ -20,9 +18,7 @@ export declare const INTERFACE_RULESET: {
|
|
|
20
18
|
given: string;
|
|
21
19
|
then: {
|
|
22
20
|
field: string;
|
|
23
|
-
function: (
|
|
24
|
-
message: string;
|
|
25
|
-
}[];
|
|
21
|
+
function: import("@stoplight/spectral-core").RulesetFunction<any, any> | import("@stoplight/spectral-core").RulesetFunctionWithValidator<any, any>;
|
|
26
22
|
}[];
|
|
27
23
|
};
|
|
28
24
|
'action-outputparams-should-have-a-title': {
|
|
@@ -32,9 +28,7 @@ export declare const INTERFACE_RULESET: {
|
|
|
32
28
|
given: string;
|
|
33
29
|
then: {
|
|
34
30
|
field: string;
|
|
35
|
-
function: (
|
|
36
|
-
message: string;
|
|
37
|
-
}[];
|
|
31
|
+
function: import("@stoplight/spectral-core").RulesetFunction<any, any> | import("@stoplight/spectral-core").RulesetFunctionWithValidator<any, any>;
|
|
38
32
|
}[];
|
|
39
33
|
};
|
|
40
34
|
'action-outputparams-must-have-a-description': {
|
|
@@ -44,9 +38,7 @@ export declare const INTERFACE_RULESET: {
|
|
|
44
38
|
given: string;
|
|
45
39
|
then: {
|
|
46
40
|
field: string;
|
|
47
|
-
function: (
|
|
48
|
-
message: string;
|
|
49
|
-
}[];
|
|
41
|
+
function: import("@stoplight/spectral-core").RulesetFunction<any, any> | import("@stoplight/spectral-core").RulesetFunctionWithValidator<any, any>;
|
|
50
42
|
}[];
|
|
51
43
|
};
|
|
52
44
|
'event-outputparams-should-have-title': {
|
|
@@ -56,9 +48,7 @@ export declare const INTERFACE_RULESET: {
|
|
|
56
48
|
given: string;
|
|
57
49
|
then: {
|
|
58
50
|
field: string;
|
|
59
|
-
function: (
|
|
60
|
-
message: string;
|
|
61
|
-
}[];
|
|
51
|
+
function: import("@stoplight/spectral-core").RulesetFunction<any, any> | import("@stoplight/spectral-core").RulesetFunctionWithValidator<any, any>;
|
|
62
52
|
}[];
|
|
63
53
|
};
|
|
64
54
|
'event-outputparams-must-have-description': {
|
|
@@ -68,9 +58,7 @@ export declare const INTERFACE_RULESET: {
|
|
|
68
58
|
given: string;
|
|
69
59
|
then: {
|
|
70
60
|
field: string;
|
|
71
|
-
function: (
|
|
72
|
-
message: string;
|
|
73
|
-
}[];
|
|
61
|
+
function: import("@stoplight/spectral-core").RulesetFunction<any, any> | import("@stoplight/spectral-core").RulesetFunctionWithValidator<any, any>;
|
|
74
62
|
}[];
|
|
75
63
|
};
|
|
76
64
|
'legacy-zui-title-should-be-removed': {
|
|
@@ -96,9 +84,7 @@ export declare const INTERFACE_RULESET: {
|
|
|
96
84
|
given: string;
|
|
97
85
|
then: {
|
|
98
86
|
field: string;
|
|
99
|
-
function: (
|
|
100
|
-
message: string;
|
|
101
|
-
}[];
|
|
87
|
+
function: import("@stoplight/spectral-core").RulesetFunction<any, any> | import("@stoplight/spectral-core").RulesetFunctionWithValidator<any, any>;
|
|
102
88
|
}[];
|
|
103
89
|
};
|
|
104
90
|
'entities-must-have-a-description': {
|
|
@@ -108,9 +94,7 @@ export declare const INTERFACE_RULESET: {
|
|
|
108
94
|
given: string;
|
|
109
95
|
then: {
|
|
110
96
|
field: string;
|
|
111
|
-
function: (
|
|
112
|
-
message: string;
|
|
113
|
-
}[];
|
|
97
|
+
function: import("@stoplight/spectral-core").RulesetFunction<any, any> | import("@stoplight/spectral-core").RulesetFunctionWithValidator<any, any>;
|
|
114
98
|
}[];
|
|
115
99
|
};
|
|
116
100
|
'entity-fields-should-have-a-title': {
|
|
@@ -120,9 +104,7 @@ export declare const INTERFACE_RULESET: {
|
|
|
120
104
|
given: string;
|
|
121
105
|
then: {
|
|
122
106
|
field: string;
|
|
123
|
-
function: (
|
|
124
|
-
message: string;
|
|
125
|
-
}[];
|
|
107
|
+
function: import("@stoplight/spectral-core").RulesetFunction<any, any> | import("@stoplight/spectral-core").RulesetFunctionWithValidator<any, any>;
|
|
126
108
|
}[];
|
|
127
109
|
};
|
|
128
110
|
'entity-fields-must-have-a-description': {
|
|
@@ -132,9 +114,7 @@ export declare const INTERFACE_RULESET: {
|
|
|
132
114
|
given: string;
|
|
133
115
|
then: {
|
|
134
116
|
field: string;
|
|
135
|
-
function: (
|
|
136
|
-
message: string;
|
|
137
|
-
}[];
|
|
117
|
+
function: import("@stoplight/spectral-core").RulesetFunction<any, any> | import("@stoplight/spectral-core").RulesetFunctionWithValidator<any, any>;
|
|
138
118
|
}[];
|
|
139
119
|
};
|
|
140
120
|
};
|
|
@@ -34,7 +34,10 @@ const INTERFACE_RULESET = {
|
|
|
34
34
|
then: [
|
|
35
35
|
{
|
|
36
36
|
field: "title",
|
|
37
|
-
function: (0, import_spectral_functions2.truthyWithMessage)(
|
|
37
|
+
function: (0, import_spectral_functions2.truthyWithMessage)({
|
|
38
|
+
failMsgMapper: ({ path, isFallback }) => `input parameter "${path.at(isFallback ? -5 : -3)}" of action "${path[1]}"`,
|
|
39
|
+
fallbackExtractor: import_spectral_functions2.titleFallbackExtractor
|
|
40
|
+
})
|
|
38
41
|
}
|
|
39
42
|
]
|
|
40
43
|
},
|
|
@@ -46,7 +49,10 @@ const INTERFACE_RULESET = {
|
|
|
46
49
|
then: [
|
|
47
50
|
{
|
|
48
51
|
field: "description",
|
|
49
|
-
function: (0, import_spectral_functions2.truthyWithMessage)(
|
|
52
|
+
function: (0, import_spectral_functions2.truthyWithMessage)({
|
|
53
|
+
failMsgMapper: ({ path, isFallback }) => `input parameter "${path.at(isFallback ? -4 : -2)}" of action "${path[1]}"`,
|
|
54
|
+
fallbackExtractor: import_spectral_functions2.descriptionFallbackExtractor
|
|
55
|
+
})
|
|
50
56
|
}
|
|
51
57
|
]
|
|
52
58
|
},
|
|
@@ -58,7 +64,10 @@ const INTERFACE_RULESET = {
|
|
|
58
64
|
then: [
|
|
59
65
|
{
|
|
60
66
|
field: "title",
|
|
61
|
-
function: (0, import_spectral_functions2.truthyWithMessage)(
|
|
67
|
+
function: (0, import_spectral_functions2.truthyWithMessage)({
|
|
68
|
+
failMsgMapper: ({ path, isFallback }) => `output parameter "${path.at(isFallback ? -5 : -3)}" of action "${path[1]}"`,
|
|
69
|
+
fallbackExtractor: import_spectral_functions2.titleFallbackExtractor
|
|
70
|
+
})
|
|
62
71
|
}
|
|
63
72
|
]
|
|
64
73
|
},
|
|
@@ -70,7 +79,10 @@ const INTERFACE_RULESET = {
|
|
|
70
79
|
then: [
|
|
71
80
|
{
|
|
72
81
|
field: "description",
|
|
73
|
-
function: (0, import_spectral_functions2.truthyWithMessage)(
|
|
82
|
+
function: (0, import_spectral_functions2.truthyWithMessage)({
|
|
83
|
+
failMsgMapper: ({ path, isFallback }) => `output parameter "${path.at(isFallback ? -4 : -2)}" of action "${path[1]}"`,
|
|
84
|
+
fallbackExtractor: import_spectral_functions2.descriptionFallbackExtractor
|
|
85
|
+
})
|
|
74
86
|
}
|
|
75
87
|
]
|
|
76
88
|
},
|
|
@@ -82,7 +94,10 @@ const INTERFACE_RULESET = {
|
|
|
82
94
|
then: [
|
|
83
95
|
{
|
|
84
96
|
field: "x-zui.title",
|
|
85
|
-
function: (0, import_spectral_functions2.truthyWithMessage)(
|
|
97
|
+
function: (0, import_spectral_functions2.truthyWithMessage)({
|
|
98
|
+
failMsgMapper: ({ path, isFallback }) => `output parameter "${path.at(isFallback ? -5 : -3)}" of event "${path[1]}"`,
|
|
99
|
+
fallbackExtractor: import_spectral_functions2.titleFallbackExtractor
|
|
100
|
+
})
|
|
86
101
|
}
|
|
87
102
|
]
|
|
88
103
|
},
|
|
@@ -94,7 +109,10 @@ const INTERFACE_RULESET = {
|
|
|
94
109
|
then: [
|
|
95
110
|
{
|
|
96
111
|
field: "description",
|
|
97
|
-
function: (0, import_spectral_functions2.truthyWithMessage)(
|
|
112
|
+
function: (0, import_spectral_functions2.truthyWithMessage)({
|
|
113
|
+
failMsgMapper: ({ path, isFallback }) => `output parameter "${path.at(isFallback ? -4 : -2)}" of event "${path[1]}"`,
|
|
114
|
+
fallbackExtractor: import_spectral_functions2.descriptionFallbackExtractor
|
|
115
|
+
})
|
|
98
116
|
}
|
|
99
117
|
]
|
|
100
118
|
},
|
|
@@ -132,7 +150,10 @@ const INTERFACE_RULESET = {
|
|
|
132
150
|
then: [
|
|
133
151
|
{
|
|
134
152
|
field: "x-zui.title",
|
|
135
|
-
function: (0, import_spectral_functions2.truthyWithMessage)(
|
|
153
|
+
function: (0, import_spectral_functions2.truthyWithMessage)({
|
|
154
|
+
failMsgMapper: ({ path, isFallback }) => `field "${path.at(isFallback ? -5 : -3)}" of entity "${path[1]}"`,
|
|
155
|
+
fallbackExtractor: import_spectral_functions2.titleFallbackExtractor
|
|
156
|
+
})
|
|
136
157
|
}
|
|
137
158
|
]
|
|
138
159
|
},
|
|
@@ -144,7 +165,10 @@ const INTERFACE_RULESET = {
|
|
|
144
165
|
then: [
|
|
145
166
|
{
|
|
146
167
|
field: "description",
|
|
147
|
-
function: (0, import_spectral_functions2.truthyWithMessage)(
|
|
168
|
+
function: (0, import_spectral_functions2.truthyWithMessage)({
|
|
169
|
+
failMsgMapper: ({ path, isFallback }) => `field "${path.at(isFallback ? -4 : -2)}" of entity "${path[1]}"`,
|
|
170
|
+
fallbackExtractor: import_spectral_functions2.descriptionFallbackExtractor
|
|
171
|
+
})
|
|
148
172
|
}
|
|
149
173
|
]
|
|
150
174
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/linter/rulesets/interface.ruleset.ts"],
|
|
4
|
-
"sourcesContent": ["import { type RulesetDefinition } from '@stoplight/spectral-core'\nimport { falsy } from '@stoplight/spectral-functions'\nimport { truthyWithMessage } from '../spectral-functions'\n\nexport const INTERFACE_RULESET = {\n extends: [],\n rules: {\n 'action-inputparams-should-have-a-title': {\n description: 'All action input parameters SHOULD have a title',\n message: '{{description}}: {{error}} SHOULD provide a non-empty title by using .title() in its Zod schema',\n severity: 'warn',\n given: '$.actions[*].input..schema.properties[*].x-zui',\n then: [\n {\n field: 'title',\n function: truthyWithMessage(({ path })
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gCAAsB;AACtB,IAAAA,
|
|
4
|
+
"sourcesContent": ["import { type RulesetDefinition } from '@stoplight/spectral-core'\nimport { falsy } from '@stoplight/spectral-functions'\nimport { descriptionFallbackExtractor, titleFallbackExtractor, truthyWithMessage } from '../spectral-functions'\n\nexport const INTERFACE_RULESET = {\n extends: [],\n rules: {\n 'action-inputparams-should-have-a-title': {\n description: 'All action input parameters SHOULD have a title',\n message: '{{description}}: {{error}} SHOULD provide a non-empty title by using .title() in its Zod schema',\n severity: 'warn',\n given: '$.actions[*].input..schema.properties[*].x-zui',\n then: [\n {\n field: 'title',\n function: truthyWithMessage({\n failMsgMapper: ({ path, isFallback }) =>\n `input parameter \"${path.at(isFallback ? -5 : -3)}\" of action \"${path[1]}\"`,\n fallbackExtractor: titleFallbackExtractor,\n }),\n },\n ],\n },\n 'action-inputparams-must-have-a-description': {\n description: 'All action input parameters MUST have a description',\n message: '{{description}}: {{error}} MUST provide a non-empty description by using .describe() in its Zod schema',\n severity: 'error',\n given: '$.actions[*].input..schema.properties[*]',\n then: [\n {\n field: 'description',\n function: truthyWithMessage({\n failMsgMapper: ({ path, isFallback }) =>\n `input parameter \"${path.at(isFallback ? -4 : -2)}\" of action \"${path[1]}\"`,\n fallbackExtractor: descriptionFallbackExtractor,\n }),\n },\n ],\n },\n 'action-outputparams-should-have-a-title': {\n description: 'All action output parameters SHOULD have a title',\n message: '{{description}}: {{error}} SHOULD provide a non-empty title by using .title() in its Zod schema',\n severity: 'warn',\n given: '$.actions[*].output..schema.properties[*].x-zui',\n then: [\n {\n field: 'title',\n function: truthyWithMessage({\n failMsgMapper: ({ path, isFallback }) =>\n `output parameter \"${path.at(isFallback ? -5 : -3)}\" of action \"${path[1]}\"`,\n fallbackExtractor: titleFallbackExtractor,\n }),\n },\n ],\n },\n 'action-outputparams-must-have-a-description': {\n description: 'All action output parameters MUST have a description',\n message: '{{description}}: {{error}} MUST provide a non-empty description by using .describe() in its Zod schema',\n severity: 'error',\n given: '$.actions[*].output..schema.properties[*]',\n then: [\n {\n field: 'description',\n function: truthyWithMessage({\n failMsgMapper: ({ path, isFallback }) =>\n `output parameter \"${path.at(isFallback ? -4 : -2)}\" of action \"${path[1]}\"`,\n fallbackExtractor: descriptionFallbackExtractor,\n }),\n },\n ],\n },\n 'event-outputparams-should-have-title': {\n description: 'All event output parameters SHOULD have a title',\n message: '{{description}}: {{error}} SHOULD provide a non-empty title by using .title() in its Zod schema',\n severity: 'warn',\n given: '$.events[*]..schema.properties[*]',\n then: [\n {\n field: 'x-zui.title',\n function: truthyWithMessage({\n failMsgMapper: ({ path, isFallback }) =>\n `output parameter \"${path.at(isFallback ? -5 : -3)}\" of event \"${path[1]}\"`,\n fallbackExtractor: titleFallbackExtractor,\n }),\n },\n ],\n },\n 'event-outputparams-must-have-description': {\n description: 'All event output parameters MUST have a description',\n message:\n '{{description}}: {{error}} SHOULD provide a non-empty description by using .describe() in its Zod schema',\n severity: 'error',\n given: '$.events[*]..schema.properties[*]',\n then: [\n {\n field: 'description',\n function: truthyWithMessage({\n failMsgMapper: ({ path, isFallback }) =>\n `output parameter \"${path.at(isFallback ? -4 : -2)}\" of event \"${path[1]}\"`,\n fallbackExtractor: descriptionFallbackExtractor,\n }),\n },\n ],\n },\n 'legacy-zui-title-should-be-removed': {\n description:\n 'Legacy ZUI title fields (ui.title) SHOULD be removed. Please use .title() in your Zod schemas instead',\n severity: 'error',\n given: '$..ui[*].title',\n then: [{ function: falsy }],\n },\n 'legacy-zui-examples-should-be-removed': {\n description: 'Legacy ZUI examples fields (ui.examples) SHOULD be removed. There are currently no alternatives',\n severity: 'hint',\n given: '$..ui[*].examples',\n then: [{ function: falsy }],\n },\n 'entities-should-have-a-title': {\n description: 'All entities SHOULD have a title',\n message: '{{description}}: {{error}} SHOULD have a non-empty title',\n severity: 'warn',\n given: '$.entities[*]',\n then: [{ field: 'title', function: truthyWithMessage(({ path }) => `entity \"${path[1]}\"`) }],\n },\n 'entities-must-have-a-description': {\n description: 'All entities MUST have a description',\n message: '{{description}}: {{error}} MUST have a non-empty description',\n severity: 'error',\n given: '$.entities[*]',\n then: [{ field: 'description', function: truthyWithMessage(({ path }) => `entity \"${path[1]}\"`) }],\n },\n 'entity-fields-should-have-a-title': {\n description: 'All entity fields SHOULD have a title',\n message: '{{description}}: {{error}} SHOULD provide a non-empty title by using .title() in its Zod schema',\n severity: 'warn',\n given: '$.entities[*]..schema.properties[*]',\n then: [\n {\n field: 'x-zui.title',\n function: truthyWithMessage({\n failMsgMapper: ({ path, isFallback }) => `field \"${path.at(isFallback ? -5 : -3)}\" of entity \"${path[1]}\"`,\n fallbackExtractor: titleFallbackExtractor,\n }),\n },\n ],\n },\n 'entity-fields-must-have-a-description': {\n description: 'All entity fields MUST have a description',\n message: '{{description}}: {{error}} MUST provide a non-empty description by using .describe() in its Zod schema',\n severity: 'error',\n given: '$.entities[*]..schema.properties[*]',\n then: [\n {\n field: 'description',\n function: truthyWithMessage({\n failMsgMapper: ({ path, isFallback }) => `field \"${path.at(isFallback ? -4 : -2)}\" of entity \"${path[1]}\"`,\n fall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;AAAA,UACrB,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
6
|
"names": ["import_spectral_functions"]
|
|
7
7
|
}
|
|
@@ -1,11 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type
|
|
1
|
+
import { RuleDefinition } from '@stoplight/spectral-core';
|
|
2
|
+
import type { JsonPath } from '@stoplight/types';
|
|
3
|
+
export declare const TRUTHY_WITH_MESSAGE_ID = "truthyWithMessage";
|
|
4
|
+
type RulesetThenFn = Exclude<RuleDefinition['then'], Array<any>>['function'];
|
|
5
|
+
type MessageFn = ({ path, isFallback }: {
|
|
3
6
|
path: (string | number)[];
|
|
7
|
+
isFallback: boolean;
|
|
4
8
|
}) => string;
|
|
9
|
+
type TruthyWithMessageOptions = {
|
|
10
|
+
failMsgMapper: MessageFn;
|
|
11
|
+
fallbackExtractor: FallbackExtractor;
|
|
12
|
+
};
|
|
13
|
+
/** Extracts a fallback result that will be tested for truthiness */
|
|
14
|
+
type FallbackExtractor = (failedPath: JsonPath, jsonPathExtractor: (fallbackPath: string) => {
|
|
15
|
+
resolvedPath: JsonPath;
|
|
16
|
+
value: any;
|
|
17
|
+
}[]) => {
|
|
18
|
+
path: JsonPath;
|
|
19
|
+
value: string;
|
|
20
|
+
} | null;
|
|
21
|
+
export declare const titleFallbackExtractor: FallbackExtractor;
|
|
22
|
+
export declare const descriptionFallbackExtractor: FallbackExtractor;
|
|
5
23
|
/**
|
|
6
24
|
* When the input is falsy, return a message that is generated by the provided function
|
|
25
|
+
*
|
|
26
|
+
* @remark When using the `fallbackExtractor`, it's expected to use a portion
|
|
27
|
+
* of the resolved path so the fallback query continues from that point.
|
|
7
28
|
*/
|
|
8
|
-
export declare
|
|
9
|
-
|
|
10
|
-
}[];
|
|
29
|
+
export declare function truthyWithMessage(failMsgMapper: MessageFn): RulesetThenFn;
|
|
30
|
+
export declare function truthyWithMessage(options: TruthyWithMessageOptions): RulesetThenFn;
|
|
11
31
|
export {};
|
|
@@ -18,19 +18,120 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var spectral_functions_exports = {};
|
|
20
20
|
__export(spectral_functions_exports, {
|
|
21
|
+
TRUTHY_WITH_MESSAGE_ID: () => TRUTHY_WITH_MESSAGE_ID,
|
|
22
|
+
descriptionFallbackExtractor: () => descriptionFallbackExtractor,
|
|
23
|
+
titleFallbackExtractor: () => titleFallbackExtractor,
|
|
21
24
|
truthyWithMessage: () => truthyWithMessage
|
|
22
25
|
});
|
|
23
26
|
module.exports = __toCommonJS(spectral_functions_exports);
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
var import_jsonpath_plus = require("jsonpath-plus");
|
|
28
|
+
var import_logger = require("../logger");
|
|
29
|
+
const TRUTHY_WITH_MESSAGE_ID = "truthyWithMessage";
|
|
30
|
+
const _anyOfFallbackExtractor = (pathFromAnyOf, options = {}) => {
|
|
31
|
+
const { pathBackoff = pathFromAnyOf.length } = options;
|
|
32
|
+
if (pathBackoff < 0 || !Number.isInteger(pathBackoff)) {
|
|
33
|
+
throw new Error("Path backoff must be a non-negative integer");
|
|
29
34
|
}
|
|
30
|
-
return
|
|
35
|
+
return (failedPath, jsonPathExtractor) => {
|
|
36
|
+
const spliceIndex = failedPath.length - pathBackoff;
|
|
37
|
+
const newPath = `$.${failedPath.toSpliced(spliceIndex, pathBackoff, "anyOf[*]", ...pathFromAnyOf).join(".")}`;
|
|
38
|
+
const match = jsonPathExtractor(newPath).find(({ value }) => typeof value === "string");
|
|
39
|
+
return match ? { value: match.value, path: match.resolvedPath } : null;
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
const titleFallbackExtractor = _anyOfFallbackExtractor(["x-zui", "title"]);
|
|
43
|
+
const descriptionFallbackExtractor = _anyOfFallbackExtractor(["description"]);
|
|
44
|
+
function truthyWithMessage(failMsgMapperOrOptions) {
|
|
45
|
+
const { failMsgMapper, fallbackExtractor } = typeof failMsgMapperOrOptions === "function" ? { failMsgMapper: failMsgMapperOrOptions } : failMsgMapperOrOptions;
|
|
46
|
+
const fn = (input, options, context) => {
|
|
47
|
+
const messages = [];
|
|
48
|
+
if (!_isFalsy(input)) {
|
|
49
|
+
return messages;
|
|
50
|
+
}
|
|
51
|
+
const logger = _extractLoggerFromOptions(options);
|
|
52
|
+
const { path } = context;
|
|
53
|
+
if (!fallbackExtractor) {
|
|
54
|
+
const message = failMsgMapper({ path, isFallback: false });
|
|
55
|
+
messages.push({ message });
|
|
56
|
+
} else {
|
|
57
|
+
const jsonPathFn = _extractJsonPath.bind(null, context.document);
|
|
58
|
+
try {
|
|
59
|
+
const fallbackResult = fallbackExtractor(path, jsonPathFn);
|
|
60
|
+
if (fallbackResult === null || _isFalsy(fallbackResult.value)) {
|
|
61
|
+
const isFallback = fallbackResult !== null;
|
|
62
|
+
const resolvedPath = isFallback ? fallbackResult.path : path;
|
|
63
|
+
if (!Array.isArray(resolvedPath)) {
|
|
64
|
+
throw new Error("The resolved path was not provided or is invalid");
|
|
65
|
+
}
|
|
66
|
+
const message = failMsgMapper({ path: resolvedPath, isFallback });
|
|
67
|
+
messages.push({ message });
|
|
68
|
+
context.path = resolvedPath;
|
|
69
|
+
}
|
|
70
|
+
} catch (thrown) {
|
|
71
|
+
const error = thrown instanceof Error ? thrown : new Error(String(thrown));
|
|
72
|
+
const message = `[${_getRuleDescriptor(context)}] Ruleset failed in either the fallback extractor or the message supplier -> ${error.message}`;
|
|
73
|
+
if (logger) {
|
|
74
|
+
logger.error(message);
|
|
75
|
+
} else {
|
|
76
|
+
messages.push({
|
|
77
|
+
message: message + "\n[IGNORE] ->"
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return messages;
|
|
83
|
+
};
|
|
84
|
+
Object.defineProperty(fn, "name", {
|
|
85
|
+
value: TRUTHY_WITH_MESSAGE_ID,
|
|
86
|
+
configurable: false,
|
|
87
|
+
writable: false
|
|
88
|
+
});
|
|
89
|
+
return fn;
|
|
90
|
+
}
|
|
91
|
+
const _getRuleDescriptor = (context) => ("name" in context.rule ? `${context.rule.name}` : context.rule.description) ?? "<unknown-rule>";
|
|
92
|
+
const _isFalsy = (input) => {
|
|
93
|
+
return !input;
|
|
94
|
+
};
|
|
95
|
+
const _parseJsonPathPointer = (pointer) => {
|
|
96
|
+
return pointer.replace(/^\//, "").split("/").map((segment) => {
|
|
97
|
+
const numOrNan = Number(segment);
|
|
98
|
+
return isNaN(numOrNan) ? segment : numOrNan;
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
const _isObjectAndHasProp = (obj, key) => {
|
|
102
|
+
return typeof obj === "object" ? _safeHasProp(obj, key) : false;
|
|
103
|
+
};
|
|
104
|
+
const _safeHasProp = (obj, key) => {
|
|
105
|
+
return {}.hasOwnProperty.call(obj ?? {}, key);
|
|
106
|
+
};
|
|
107
|
+
const _extractJsonPath = (schemaDocument, fallbackJsonPath) => {
|
|
108
|
+
const output = (0, import_jsonpath_plus.JSONPath)({
|
|
109
|
+
path: fallbackJsonPath,
|
|
110
|
+
json: schemaDocument.data,
|
|
111
|
+
resultType: "all"
|
|
112
|
+
});
|
|
113
|
+
if (!Array.isArray(output)) {
|
|
114
|
+
throw new Error("JSONPath output is not an array");
|
|
115
|
+
}
|
|
116
|
+
if (!output.every((result) => _safeHasProp(result, "value") && _safeHasProp(result, "pointer"))) {
|
|
117
|
+
throw new Error("Fallback JSONPath output is missing either one or both the 'value' or 'pointer' property");
|
|
118
|
+
}
|
|
119
|
+
return output.map((result) => {
|
|
120
|
+
const resolvedPath = _parseJsonPathPointer(result.pointer);
|
|
121
|
+
return { resolvedPath, value: result.value };
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
const _extractLoggerFromOptions = (options) => {
|
|
125
|
+
if (!_isObjectAndHasProp(options, "logger")) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
128
|
+
return options.logger instanceof import_logger.Logger ? options.logger : null;
|
|
31
129
|
};
|
|
32
130
|
// Annotate the CommonJS export names for ESM import in node:
|
|
33
131
|
0 && (module.exports = {
|
|
132
|
+
TRUTHY_WITH_MESSAGE_ID,
|
|
133
|
+
descriptionFallbackExtractor,
|
|
134
|
+
titleFallbackExtractor,
|
|
34
135
|
truthyWithMessage
|
|
35
136
|
});
|
|
36
137
|
//# sourceMappingURL=spectral-functions.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/linter/spectral-functions.ts"],
|
|
4
|
-
"sourcesContent": ["import { RulesetFunctionContext } from '@stoplight/spectral-core'\n\ntype MessageFn = ({ path }: { path: (string | number)[] }) => string\n\n/**\n * When the input is falsy, return a message that is generated by the provided function\n */\nexport
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
4
|
+
"sourcesContent": ["import { IFunctionResult, RuleDefinition, RulesetFunctionContext } from '@stoplight/spectral-core'\nimport type { JsonPath, Segment } from '@stoplight/types'\nimport { JSONPath } from 'jsonpath-plus'\nimport { Logger } from '../logger'\n\nexport const TRUTHY_WITH_MESSAGE_ID = 'truthyWithMessage'\n\ntype SpectralDocument = RulesetFunctionContext['document']\ntype RulesetThenFn = Exclude<RuleDefinition['then'], Array<any>>['function']\n\ntype MessageFn = ({ path, isFallback }: { path: (string | number)[]; isFallback: boolean }) => string\ntype TruthyWithMessageOptions = {\n failMsgMapper: MessageFn\n fallbackExtractor: FallbackExtractor\n}\n\n/** Extracts a fallback result that will be tested for truthiness */\ntype FallbackExtractor = (\n failedPath: JsonPath,\n jsonPathExtractor: (fallbackPath: string) => { resolvedPath: JsonPath; value: any }[]\n) => { path: JsonPath; value: string } | null\n\nconst _anyOfFallbackExtractor = (\n /** The relative path from within the \"anyOf\" node */\n pathFromAnyOf: Segment[],\n options: { pathBackoff?: number } = {}\n): FallbackExtractor => {\n const { pathBackoff = pathFromAnyOf.length } = options\n\n if (pathBackoff < 0 || !Number.isInteger(pathBackoff)) {\n throw new Error('Path backoff must be a non-negative integer')\n }\n\n return (failedPath, jsonPathExtractor) => {\n const spliceIndex = failedPath.length - pathBackoff\n const newPath = `$.${failedPath.toSpliced(spliceIndex, pathBackoff, 'anyOf[*]', ...pathFromAnyOf).join('.')}`\n const match = jsonPathExtractor(newPath).find(({ value }) => typeof value === 'string')\n return match ? { value: match.value, path: match.resolvedPath } : null\n }\n}\n\nexport const titleFallbackExtractor: FallbackExtractor = _anyOfFallbackExtractor(['x-zui', 'title'])\nexport const descriptionFallbackExtractor: FallbackExtractor = _anyOfFallbackExtractor(['description'])\n\n/**\n * When the input is falsy, return a message that is generated by the provided function\n *\n * @remark When using the `fallbackExtractor`, it's expected to use a portion\n * of the resolved path so the fallback query continues from that point.\n */\nexport function truthyWithMessage(failMsgMapper: MessageFn): RulesetThenFn\nexport function truthyWithMessage(options: TruthyWithMessageOptions): RulesetThenFn\nexport function truthyWithMessage(failMsgMapperOrOptions: MessageFn | TruthyWithMessageOptions): RulesetThenFn {\n const { failMsgMapper, fallbackExtractor } =\n typeof failMsgMapperOrOptions === 'function' ? { failMsgMapper: failMsgMapperOrOptions } : failMsgMapperOrOptions\n\n const fn = (input: string, options: unknown, context: RulesetFunctionContext) => {\n const messages: IFunctionResult[] = []\n\n if (!_isFalsy(input)) {\n return messages\n }\n\n const logger = _extractLoggerFromOptions(options)\n\n const { path } = context\n if (!fallbackExtractor) {\n const message = failMsgMapper({ path, isFallback: false })\n messages.push({ message })\n } else {\n const jsonPathFn = _extractJsonPath.bind(null, context.document)\n try {\n const fallbackResult = fallbackExtractor(path, jsonPathFn)\n if (fallbackResult === null || _isFalsy(fallbackResult.value)) {\n const isFallback = fallbackResult !== null\n const resolvedPath = isFallback ? fallbackResult.path : path\n\n if (!Array.isArray(resolvedPath)) {\n // This is likely due to a mistake in the fallbackExtractor,\n // which is easy to make since there are \"any\" types involved\n throw new Error('The resolved path was not provided or is invalid')\n }\n\n const message = failMsgMapper({ path: resolvedPath, isFallback })\n messages.push({ message })\n\n // This is for the unit tests\n context.path = resolvedPath\n }\n } catch (thrown: unknown) {\n const error = thrown instanceof Error ? thrown : new Error(String(thrown))\n const message = `[${_getRuleDescriptor(context)}] Ruleset failed in either the fallback extractor or the message supplier -> ${error.message}`\n if (logger) {\n logger.error(message)\n } else {\n messages.push({\n message: message + '\\n[IGNORE] ->',\n })\n }\n }\n }\n\n return messages\n }\n\n Object.defineProperty(fn, 'name', {\n value: TRUTHY_WITH_MESSAGE_ID,\n configurable: false,\n writable: false,\n })\n return fn\n}\n\nconst _getRuleDescriptor = (context: RulesetFunctionContext): string | null =>\n ('name' in context.rule ? `${context.rule.name}` : context.rule.description) ?? '<unknown-rule>'\n\nconst _isFalsy = (input: string): boolean => {\n return !input\n}\n\n/** Parses the equivalent of Stoplight's JsonPath from the JsonPath-plus \"pointer\" output */\nconst _parseJsonPathPointer = (pointer: string): JsonPath => {\n return pointer\n .replace(/^\\//, '')\n .split('/')\n .map((segment: string) => {\n // Do not use \"parseInt\" here\n const numOrNan = Number(segment)\n return isNaN(numOrNan) ? segment : numOrNan\n })\n}\n\nconst _isObjectAndHasProp = <K extends string>(obj: unknown, key: K): obj is Record<K, unknown> => {\n return typeof obj === 'object' ? _safeHasProp(obj, key) : false\n}\n\n// This is safer than `\"key\" in obj` when\n// dealing with an unknown/any variable\nconst _safeHasProp = (obj: unknown, key: string) => {\n return {}.hasOwnProperty.call(obj ?? {}, key)\n}\n\nconst _extractJsonPath = (schemaDocument: SpectralDocument, fallbackJsonPath: string) => {\n const output = JSONPath({\n path: fallbackJsonPath,\n json: schemaDocument.data as object,\n resultType: 'all',\n })\n\n // Sanity check (Error should never actually be thrown)\n if (!Array.isArray(output)) {\n throw new Error('JSONPath output is not an array')\n }\n\n // There is a \"path\" property, but it's serialized in a way that is harder to parse than \"pointer\"\n if (!output.every((result) => _safeHasProp(result, 'value') && _safeHasProp(result, 'pointer'))) {\n throw new Error(\"Fallback JSONPath output is missing either one or both the 'value' or 'pointer' property\")\n }\n\n return output.map((result) => {\n const resolvedPath = _parseJsonPathPointer(result.pointer)\n return { resolvedPath, value: result.value }\n })\n}\n\nconst _extractLoggerFromOptions = (options: unknown): Logger | null => {\n if (!_isObjectAndHasProp(options, 'logger')) {\n return null\n }\n\n return options.logger instanceof Logger ? options.logger : null\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,2BAAyB;AACzB,oBAAuB;AAEhB,MAAM,yBAAyB;AAiBtC,MAAM,0BAA0B,CAE9B,eACA,UAAoC,CAAC,MACf;AACtB,QAAM,EAAE,cAAc,cAAc,OAAO,IAAI;AAE/C,MAAI,cAAc,KAAK,CAAC,OAAO,UAAU,WAAW,GAAG;AACrD,UAAM,IAAI,MAAM,6CAA6C;AAAA,EAC/D;AAEA,SAAO,CAAC,YAAY,sBAAsB;AACxC,UAAM,cAAc,WAAW,SAAS;AACxC,UAAM,UAAU,KAAK,WAAW,UAAU,aAAa,aAAa,YAAY,GAAG,aAAa,EAAE,KAAK,GAAG,CAAC;AAC3G,UAAM,QAAQ,kBAAkB,OAAO,EAAE,KAAK,CAAC,EAAE,MAAM,MAAM,OAAO,UAAU,QAAQ;AACtF,WAAO,QAAQ,EAAE,OAAO,MAAM,OAAO,MAAM,MAAM,aAAa,IAAI;AAAA,EACpE;AACF;AAEO,MAAM,yBAA4C,wBAAwB,CAAC,SAAS,OAAO,CAAC;AAC5F,MAAM,+BAAkD,wBAAwB,CAAC,aAAa,CAAC;AAU/F,SAAS,kBAAkB,wBAA6E;AAC7G,QAAM,EAAE,eAAe,kBAAkB,IACvC,OAAO,2BAA2B,aAAa,EAAE,eAAe,uBAAuB,IAAI;AAE7F,QAAM,KAAK,CAAC,OAAe,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"names": []
|
|
7
7
|
}
|
|
@@ -31,7 +31,6 @@ __export(file_watcher_exports, {
|
|
|
31
31
|
FileWatcher: () => FileWatcher
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(file_watcher_exports);
|
|
34
|
-
var import_watcher = __toESM(require("@parcel/watcher"));
|
|
35
34
|
var import_concurrency_utils = require("./concurrency-utils");
|
|
36
35
|
var import_event_emitter = require("./event-emitter");
|
|
37
36
|
class FileWatcher {
|
|
@@ -55,7 +54,8 @@ class FileWatcher {
|
|
|
55
54
|
if (opt?.debounceMs) {
|
|
56
55
|
subscriptionHandler = (0, import_concurrency_utils.debounceAsync)(subscriptionHandler, opt.debounceMs);
|
|
57
56
|
}
|
|
58
|
-
const
|
|
57
|
+
const watcher = await import("@parcel/watcher");
|
|
58
|
+
const subscription = await watcher.subscribe(dir, subscriptionHandler, opt);
|
|
59
59
|
return new FileWatcher(subscription, eventEmitter);
|
|
60
60
|
}
|
|
61
61
|
async close() {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/utils/file-watcher.ts"],
|
|
4
|
-
"sourcesContent": ["import watcher from '@parcel/watcher'\nimport { debounceAsync } from './concurrency-utils'\nimport { EventEmitter } from './event-emitter'\n\nexport type FileChangeHandler = (events: watcher.Event[]) => Promise<void>\n\ntype EmptyObject = Record<never, never>\ntype FileWatcherEvent = {\n error: unknown\n close: EmptyObject\n}\n\ntype FileWatcherOptions = watcher.Options & {\n debounceMs?: number\n}\n\n/**\n * Wraps the Parcel file watcher to ensure errors can be catched in an async/await fashion\n */\nexport class FileWatcher {\n public static async watch(dir: string, fn: FileChangeHandler, opt?: FileWatcherOptions) {\n const eventEmitter = new EventEmitter<FileWatcherEvent>()\n\n let subscriptionHandler = async (err: Error | null, events: watcher.Event[]) => {\n if (err) {\n eventEmitter.emit('error', err)\n return\n }\n\n try {\n await fn(events)\n } catch (thrown) {\n eventEmitter.emit('error', thrown)\n }\n }\n\n if (opt?.debounceMs) {\n subscriptionHandler = debounceAsync(subscriptionHandler, opt.debounceMs)\n }\n\n const subscription = await watcher.subscribe(dir, subscriptionHandler, opt)\n return new FileWatcher(subscription, eventEmitter)\n }\n\n private constructor(\n private _subscription: watcher.AsyncSubscription,\n private _errorEmitter: EventEmitter<FileWatcherEvent>\n ) {}\n\n public async close() {\n await this._subscription.unsubscribe()\n this._errorEmitter.emit('close', {})\n }\n\n public wait = () =>\n new Promise((resolve, reject) => {\n this._errorEmitter.once('error', reject)\n this._errorEmitter.once('close', resolve)\n })\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;
|
|
6
|
-
"names": [
|
|
4
|
+
"sourcesContent": ["import type watcher from '@parcel/watcher'\nimport { debounceAsync } from './concurrency-utils'\nimport { EventEmitter } from './event-emitter'\n\nexport type FileChangeHandler = (events: watcher.Event[]) => Promise<void>\n\ntype EmptyObject = Record<never, never>\ntype FileWatcherEvent = {\n error: unknown\n close: EmptyObject\n}\n\ntype FileWatcherOptions = watcher.Options & {\n debounceMs?: number\n}\n\n/**\n * Wraps the Parcel file watcher to ensure errors can be catched in an async/await fashion\n */\nexport class FileWatcher {\n public static async watch(dir: string, fn: FileChangeHandler, opt?: FileWatcherOptions) {\n const eventEmitter = new EventEmitter<FileWatcherEvent>()\n\n let subscriptionHandler = async (err: Error | null, events: watcher.Event[]) => {\n if (err) {\n eventEmitter.emit('error', err)\n return\n }\n\n try {\n await fn(events)\n } catch (thrown) {\n eventEmitter.emit('error', thrown)\n }\n }\n\n if (opt?.debounceMs) {\n subscriptionHandler = debounceAsync(subscriptionHandler, opt.debounceMs)\n }\n const watcher = await import('@parcel/watcher')\n\n const subscription = await watcher.subscribe(dir, subscriptionHandler, opt)\n return new FileWatcher(subscription, eventEmitter)\n }\n\n private constructor(\n private _subscription: watcher.AsyncSubscription,\n private _errorEmitter: EventEmitter<FileWatcherEvent>\n ) {}\n\n public async close() {\n await this._subscription.unsubscribe()\n this._errorEmitter.emit('close', {})\n }\n\n public wait = () =>\n new Promise((resolve, reject) => {\n this._errorEmitter.once('error', reject)\n this._errorEmitter.once('close', resolve)\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,+BAA8B;AAC9B,2BAA6B;AAiBtB,MAAM,YAAY;AAAA,EA0Bf,YACE,eACA,eACR;AAFQ;AACA;AAAA,EACP;AAAA,EA5BH,aAAoB,MAAM,KAAa,IAAuB,KAA0B;AACtF,UAAM,eAAe,IAAI,kCAA+B;AAExD,QAAI,sBAAsB,OAAO,KAAmB,WAA4B;AAC9E,UAAI,KAAK;AACP,qBAAa,KAAK,SAAS,GAAG;AAC9B;AAAA,MACF;AAEA,UAAI;AACF,cAAM,GAAG,MAAM;AAAA,MACjB,SAAS,QAAQ;AACf,qBAAa,KAAK,SAAS,MAAM;AAAA,MACnC;AAAA,IACF;AAEA,QAAI,KAAK,YAAY;AACnB,gCAAsB,wCAAc,qBAAqB,IAAI,UAAU;AAAA,IACzE;AACA,UAAM,UAAU,MAAM,OAAO,iBAAiB;AAE9C,UAAM,eAAe,MAAM,QAAQ,UAAU,KAAK,qBAAqB,GAAG;AAC1E,WAAO,IAAI,YAAY,cAAc,YAAY;AAAA,EACnD;AAAA,EAOA,MAAa,QAAQ;AACnB,UAAM,KAAK,cAAc,YAAY;AACrC,SAAK,cAAc,KAAK,SAAS,CAAC,CAAC;AAAA,EACrC;AAAA,EAEO,OAAO,MACZ,IAAI,QAAQ,CAAC,SAAS,WAAW;AAC/B,SAAK,cAAc,KAAK,SAAS,MAAM;AACvC,SAAK,cAAc,KAAK,SAAS,OAAO;AAAA,EAC1C,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botpress/cli",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "Botpress CLI",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"build": "pnpm run build:types && pnpm run bundle && pnpm run template:gen",
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@apidevtools/json-schema-ref-parser": "^11.7.0",
|
|
28
28
|
"@botpress/chat": "0.5.4",
|
|
29
|
-
"@botpress/client": "1.
|
|
30
|
-
"@botpress/sdk": "5.0.
|
|
29
|
+
"@botpress/client": "1.28.0",
|
|
30
|
+
"@botpress/sdk": "5.0.2",
|
|
31
31
|
"@bpinternal/const": "^0.1.0",
|
|
32
32
|
"@bpinternal/tunnel": "^0.1.1",
|
|
33
33
|
"@bpinternal/verel": "^0.2.0",
|
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
"dotenv": "^16.4.4",
|
|
46
46
|
"esbuild": "^0.25.10",
|
|
47
47
|
"handlebars": "^4.7.8",
|
|
48
|
+
"jsonpath-plus": "^10.3.0",
|
|
48
49
|
"latest-version": "5.1.0",
|
|
49
50
|
"lodash": "^4.17.21",
|
|
50
51
|
"prettier": "^3.4.2",
|
|
@@ -56,6 +57,7 @@
|
|
|
56
57
|
},
|
|
57
58
|
"devDependencies": {
|
|
58
59
|
"@bpinternal/log4bot": "^0.0.4",
|
|
60
|
+
"@stoplight/types": "^14.1.1",
|
|
59
61
|
"@types/bluebird": "^3.5.38",
|
|
60
62
|
"@types/ini": "^4.1.1",
|
|
61
63
|
"@types/json-schema": "^7.0.12",
|