Skip to content

Commit 6600461

Browse files
backstage-servicegithub-actions[bot]djanickova
authored
scaffolder-backend-module-servicenow - version:bump to v1.41.1 (#4741)
* v1.41.1 version bump * Type error in Scaffolder backend module servicenow/v1.41.1 (#4812) * fix: use zod from param in createTemplateAction Signed-off-by: Diana Janickova <[email protected]> * fix: use expected sysId field in tests Signed-off-by: Diana Janickova <[email protected]> * mod: remove zod from dependencies Signed-off-by: Diana Janickova <[email protected]> * mod: generate API report Signed-off-by: Diana Janickova <[email protected]> * fix: add missing fields Signed-off-by: Diana Janickova <[email protected]> --------- Signed-off-by: Diana Janickova <[email protected]> --------- Signed-off-by: Diana Janickova <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Diana Janickova <[email protected]>
1 parent 378488a commit 6600461

File tree

16 files changed

+632
-541
lines changed

16 files changed

+632
-541
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@backstage-community/plugin-scaffolder-backend-module-servicenow': minor
3+
---
4+
5+
Backstage version bump to v1.41.1
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "1.39.0"
2+
"version": "1.41.1"
33
}

workspaces/scaffolder-backend-module-servicenow/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
"directory": "workspaces/scaffolder-backend-module-servicenow"
3636
},
3737
"devDependencies": {
38-
"@backstage/cli": "^0.32.1",
38+
"@backstage/cli": "^0.33.1",
3939
"@backstage/e2e-test-utils": "^0.1.1",
40-
"@backstage/repo-tools": "^0.13.3",
40+
"@backstage/repo-tools": "^0.15.0",
4141
"@changesets/cli": "^2.27.1",
4242
"knip": "^5.27.4",
4343
"node-gyp": "^9.0.0",

workspaces/scaffolder-backend-module-servicenow/plugins/scaffolder-backend-module-servicenow/package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,17 @@
4040
"openapi": "npx openapi-typescript-codegen"
4141
},
4242
"dependencies": {
43-
"@backstage/backend-plugin-api": "^1.3.1",
44-
"@backstage/plugin-scaffolder-node": "^0.8.2",
43+
"@backstage/backend-plugin-api": "^1.4.1",
44+
"@backstage/plugin-scaffolder-node": "^0.10.0",
4545
"abort-controller": "^3.0.0",
4646
"axios": "^1.7.4",
4747
"form-data": "^4.0.0",
48-
"yaml": "^2.3.3",
49-
"zod": "^3.22.4"
48+
"yaml": "^2.3.3"
5049
},
5150
"devDependencies": {
52-
"@backstage/cli": "^0.32.1",
53-
"@backstage/config": "^1.3.2",
54-
"@backstage/plugin-scaffolder-node-test-utils": "^0.2.2",
51+
"@backstage/cli": "^0.33.1",
52+
"@backstage/config": "^1.3.3",
53+
"@backstage/plugin-scaffolder-node-test-utils": "^0.3.1",
5554
"@backstage/types": "^1.2.1",
5655
"@hey-api/openapi-ts": "0.78.3",
5756
"@types/node-fetch": "2.6.12",

workspaces/scaffolder-backend-module-servicenow/plugins/scaffolder-backend-module-servicenow/report.api.md

Lines changed: 97 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,22 @@ export function createNowActions(
2020
// @public
2121
export const createRecordAction: (
2222
options: CreateActionOptions,
23-
) => TemplateAction;
23+
) => TemplateAction<
24+
{
25+
tableName: string;
26+
requestBody?: Record<PropertyKey, unknown> | undefined;
27+
sysparmDisplayValue?: 'true' | 'false' | 'all' | undefined;
28+
sysparmExcludeReferenceLink?: boolean | undefined;
29+
sysparmFields?: string[] | undefined;
30+
sysparmInputDisplayValue?: boolean | undefined;
31+
sysparmSuppressAutoSysField?: boolean | undefined;
32+
sysparmView?: string | undefined;
33+
},
34+
{
35+
[x: string]: any;
36+
},
37+
'v2'
38+
>;
2439

2540
// @public
2641
export function createServiceNowActions(
@@ -35,22 +50,81 @@ export function createTableActions(
3550
// @public
3651
export const deleteRecordAction: (
3752
options: CreateActionOptions,
38-
) => TemplateAction;
53+
) => TemplateAction<
54+
{
55+
tableName: string;
56+
sysId: string;
57+
sysparmQueryNoDomain?: boolean | undefined;
58+
},
59+
{
60+
[x: string]: any;
61+
},
62+
'v2'
63+
>;
3964

4065
// @public
4166
export const modifyRecordAction: (
4267
options: CreateActionOptions,
43-
) => TemplateAction;
68+
) => TemplateAction<
69+
{
70+
tableName: string;
71+
sysId: string;
72+
requestBody?: Record<PropertyKey, unknown> | undefined;
73+
sysparmDisplayValue?: 'true' | 'false' | 'all' | undefined;
74+
sysparmExcludeReferenceLink?: boolean | undefined;
75+
sysparmFields?: string[] | undefined;
76+
sysparmInputDisplayValue?: boolean | undefined;
77+
sysparmSuppressAutoSysField?: boolean | undefined;
78+
sysparmView?: string | undefined;
79+
sysparmQueryNoDomain?: boolean | undefined;
80+
},
81+
{
82+
[x: string]: any;
83+
},
84+
'v2'
85+
>;
4486

4587
// @public
4688
export const retrieveRecordAction: (
4789
options: CreateActionOptions,
48-
) => TemplateAction;
90+
) => TemplateAction<
91+
{
92+
tableName: string;
93+
sysId: string;
94+
sysparmDisplayValue?: 'true' | 'false' | 'all' | undefined;
95+
sysparmExcludeReferenceLink?: boolean | undefined;
96+
sysparmFields?: string[] | undefined;
97+
sysparmView?: string | undefined;
98+
sysparmQueryNoDomain?: boolean | undefined;
99+
},
100+
{
101+
[x: string]: any;
102+
},
103+
'v2'
104+
>;
49105

50106
// @public
51107
export const retrieveRecordsAction: (
52108
options: CreateActionOptions,
53-
) => TemplateAction;
109+
) => TemplateAction<
110+
{
111+
tableName: string;
112+
sysparmQuery?: string | undefined;
113+
sysparmDisplayValue?: 'true' | 'false' | 'all' | undefined;
114+
sysparmExcludeReferenceLink?: boolean | undefined;
115+
sysparmSuppressPaginationHeader?: boolean | undefined;
116+
sysparmFields?: string[] | undefined;
117+
sysparmLimit?: number | undefined;
118+
sysparmView?: string | undefined;
119+
sysparmQueryCategory?: string | undefined;
120+
sysparmQueryNoDomain?: boolean | undefined;
121+
sysparmNoCount?: boolean | undefined;
122+
},
123+
{
124+
[x: string]: any;
125+
},
126+
'v2'
127+
>;
54128

55129
// @public (undocumented)
56130
const scaffolderModuleServicenowActions: BackendFeature;
@@ -59,7 +133,24 @@ export default scaffolderModuleServicenowActions;
59133
// @public
60134
export const updateRecordAction: (
61135
options: CreateActionOptions,
62-
) => TemplateAction;
136+
) => TemplateAction<
137+
{
138+
tableName: string;
139+
sysId: string;
140+
requestBody?: Record<PropertyKey, unknown> | undefined;
141+
sysparmDisplayValue?: 'true' | 'false' | 'all' | undefined;
142+
sysparmExcludeReferenceLink?: boolean | undefined;
143+
sysparmFields?: string[] | undefined;
144+
sysparmInputDisplayValue?: boolean | undefined;
145+
sysparmSuppressAutoSysField?: boolean | undefined;
146+
sysparmView?: string | undefined;
147+
sysparmQueryNoDomain?: boolean | undefined;
148+
},
149+
{
150+
[x: string]: any;
151+
},
152+
'v2'
153+
>;
63154

64155
// (No @packageDocumentation comment for this package)
65156
```

workspaces/scaffolder-backend-module-servicenow/plugins/scaffolder-backend-module-servicenow/src/actions/servicenow/now/table/create-record.ts

Lines changed: 57 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import {
17-
createTemplateAction,
18-
type TemplateAction,
19-
} from '@backstage/plugin-scaffolder-node';
20-
21-
import { z } from 'zod';
16+
import { createTemplateAction } from '@backstage/plugin-scaffolder-node';
2217

2318
import {
2419
ApiError,
@@ -30,58 +25,6 @@ import { updateOpenAPIConfig } from './helpers';
3025

3126
import { examples } from './create-record.example';
3227

33-
/**
34-
* Schema for the input to the `createRecord` action.
35-
*
36-
* @see {@link https://developer.servicenow.com/dev.do#!/reference/api/vancouver/rest/c_TableAPI}
37-
*/
38-
const schemaInput = z.object({
39-
tableName: z
40-
.string()
41-
.min(1)
42-
.describe('Name of the table in which to save the record'),
43-
requestBody: z
44-
.custom<Record<PropertyKey, unknown>>()
45-
.optional()
46-
.describe(
47-
'Field name and the associated value for each parameter to define in the specified record',
48-
),
49-
sysparmDisplayValue: z
50-
.enum(['true', 'false', 'all'])
51-
.optional()
52-
.describe(
53-
'Return field display values (true), actual values (false), or both (all) (default: false)',
54-
),
55-
sysparmExcludeReferenceLink: z
56-
.boolean()
57-
.optional()
58-
.describe(
59-
'True to exclude Table API links for reference fields (default: false)',
60-
),
61-
sysparmFields: z
62-
.array(z.string().min(1))
63-
.optional()
64-
.describe('An array of fields to return in the response'),
65-
sysparmInputDisplayValue: z
66-
.boolean()
67-
.optional()
68-
.describe(
69-
'Set field values using their display value (true) or actual value (false) (default: false)',
70-
),
71-
sysparmSuppressAutoSysField: z
72-
.boolean()
73-
.optional()
74-
.describe(
75-
'True to suppress auto generation of system fields (default: false)',
76-
),
77-
sysparmView: z
78-
.string()
79-
.optional()
80-
.describe(
81-
'Render the response according to the specified UI view (overridden by sysparm_fields)',
82-
),
83-
});
84-
8528
const id = 'servicenow:now:table:createRecord';
8629

8730
/**
@@ -90,9 +33,7 @@ const id = 'servicenow:now:table:createRecord';
9033
* @param options - options to configure the action
9134
* @returns TemplateAction - an action handler
9235
*/
93-
export const createRecordAction = (
94-
options: CreateActionOptions,
95-
): TemplateAction => {
36+
export const createRecordAction = (options: CreateActionOptions) => {
9637
const { config } = options;
9738

9839
return createTemplateAction({
@@ -101,12 +42,64 @@ export const createRecordAction = (
10142
description:
10243
'Inserts one record in the specified table. Multiple record insertion is not supported by this method',
10344
schema: {
104-
input: schemaInput,
45+
input: {
46+
tableName: z =>
47+
z
48+
.string()
49+
.min(1)
50+
.describe('Name of the table in which to save the record'),
51+
requestBody: z =>
52+
z
53+
.custom<Record<PropertyKey, unknown>>()
54+
.optional()
55+
.describe(
56+
'Field name and the associated value for each parameter to define in the specified record',
57+
),
58+
sysparmDisplayValue: z =>
59+
z
60+
.enum(['true', 'false', 'all'])
61+
.optional()
62+
.describe(
63+
'Return field display values (true), actual values (false), or both (all) (default: false)',
64+
),
65+
sysparmExcludeReferenceLink: z =>
66+
z
67+
.boolean()
68+
.optional()
69+
.describe(
70+
'True to exclude Table API links for reference fields (default: false)',
71+
),
72+
sysparmFields: z =>
73+
z
74+
.array(z.string().min(1))
75+
.optional()
76+
.describe('An array of fields to return in the response'),
77+
sysparmInputDisplayValue: z =>
78+
z
79+
.boolean()
80+
.optional()
81+
.describe(
82+
'Set field values using their display value (true) or actual value (false) (default: false)',
83+
),
84+
sysparmSuppressAutoSysField: z =>
85+
z
86+
.boolean()
87+
.optional()
88+
.describe(
89+
'True to suppress auto generation of system fields (default: false)',
90+
),
91+
sysparmView: z =>
92+
z
93+
.string()
94+
.optional()
95+
.describe(
96+
'Render the response according to the specified UI view (overridden by sysparm_fields)',
97+
),
98+
},
10599
},
106100

107101
async handler(ctx) {
108-
// FIXME: remove the type assertion once backstage properly infers the type
109-
const input = ctx.input as z.infer<typeof schemaInput>;
102+
const input = ctx.input;
110103

111104
updateOpenAPIConfig(OpenAPI, config);
112105

workspaces/scaffolder-backend-module-servicenow/plugins/scaffolder-backend-module-servicenow/src/actions/servicenow/now/table/delete-record.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ describe('deleteRecord', () => {
135135
it('should throw an error if the user is not authenticated', async () => {
136136
const input = {
137137
tableName: 'incident',
138-
valid: 'valid-sys-id',
138+
sysId: 'valid-sys-id',
139139
};
140140

141141
const context = {

0 commit comments

Comments
 (0)