@pipedream/servicenow 0.8.2 → 0.9.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.
@@ -5,7 +5,7 @@ export default {
5
5
  key: "servicenow-create-table-record",
6
6
  name: "Create Table Record",
7
7
  description: "Inserts one record in the specified table. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_TableAPI.html#title_table-POST)",
8
- version: "1.0.2",
8
+ version: "1.0.3",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "servicenow-delete-table-record",
5
5
  name: "Delete Table Record",
6
6
  description: "Deletes the specified record from a table. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_TableAPI.html#title_table-DELETE)",
7
- version: "0.0.3",
7
+ version: "0.0.4",
8
8
  annotations: {
9
9
  destructiveHint: true,
10
10
  openWorldHint: true,
@@ -23,6 +23,9 @@ export default {
23
23
  propDefinition: [
24
24
  servicenow,
25
25
  "recordId",
26
+ (c) => ({
27
+ table: c.table,
28
+ }),
26
29
  ],
27
30
  },
28
31
  queryNoDomain: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "servicenow-get-record-counts-by-field",
6
6
  name: "Get Record Counts by Field",
7
7
  description: "Retrieves the count of records grouped by a specified field from a ServiceNow table. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_AggregateAPI.html#title_aggregate-GET-stats)",
8
- version: "0.0.3",
8
+ version: "0.0.4",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -4,7 +4,7 @@ export default {
4
4
  key: "servicenow-get-table-record-by-id",
5
5
  name: "Get Table Record by ID",
6
6
  description: "Retrieves a single record from a table by its ID. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_TableAPI.html#title_table-GET-id)",
7
- version: "1.0.2",
7
+ version: "1.0.3",
8
8
  annotations: {
9
9
  destructiveHint: false,
10
10
  openWorldHint: true,
@@ -23,6 +23,9 @@ export default {
23
23
  propDefinition: [
24
24
  servicenow,
25
25
  "recordId",
26
+ (c) => ({
27
+ table: c.table,
28
+ }),
26
29
  ],
27
30
  },
28
31
  responseDataFormat: {
@@ -5,7 +5,7 @@ export default {
5
5
  key: "servicenow-get-table-records",
6
6
  name: "Get Table Records",
7
7
  description: "Retrieves multiple records for the specified table. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_TableAPI.html#title_table-GET)",
8
- version: "1.0.2",
8
+ version: "1.0.3",
9
9
  annotations: {
10
10
  destructiveHint: false,
11
11
  openWorldHint: true,
@@ -0,0 +1,97 @@
1
+ import servicenow from "../../servicenow.app.mjs";
2
+
3
+ export default {
4
+ key: "servicenow-list-tables",
5
+ name: "List Tables",
6
+ description: "List all tables in the ServiceNow instance. [See the documentation](https://www.servicenow.com/docs/r/api-reference/rest-apis/c_TableAPI.html)",
7
+ version: "0.0.2",
8
+ type: "action",
9
+ annotations: {
10
+ destructiveHint: false,
11
+ openWorldHint: true,
12
+ readOnlyHint: true,
13
+ },
14
+ props: {
15
+ servicenow,
16
+ query: {
17
+ label: "Query",
18
+ type: "string",
19
+ description: "An [encoded query string](https://www.servicenow.com/docs/bundle/zurich-platform-user-interface/page/use/using-lists/concept/c_EncodedQueryStrings.html) to filter records by (e.g., `active=true^priority=1`). This overrides any other filters set.",
20
+ optional: true,
21
+ },
22
+ filterCreatedAtDate: {
23
+ type: "string",
24
+ label: "Filter by Date Created",
25
+ description: "Return records created only after the given date, in the format `YYYY-MM-DD HH:MM:SS` (e.g. `2026-01-01 00:00:00`).",
26
+ optional: true,
27
+ },
28
+ filterUpdatedAtDate: {
29
+ type: "string",
30
+ label: "Filter by Date Updated",
31
+ description: "Return records updated only after the given date, in the format `YYYY-MM-DD HH:MM:SS` (e.g. `2026-01-01 00:00:00`).",
32
+ optional: true,
33
+ },
34
+ filterActive: {
35
+ type: "boolean",
36
+ label: "Filter by Active",
37
+ description: "If set to `true`, only return records that are active. If set to `false`, only return records that are inactive. May not be available for all tables.",
38
+ optional: true,
39
+ },
40
+ limit: {
41
+ type: "integer",
42
+ label: "Limit",
43
+ description: "The maximum number of results to return. Default: 100. Max: 200",
44
+ min: 1,
45
+ max: 200,
46
+ default: 100,
47
+ optional: true,
48
+ },
49
+ },
50
+ async run({ $ }) {
51
+ let query = this.query;
52
+ if (!query) {
53
+ const filters = [];
54
+ if (this.filterCreatedAtDate) {
55
+ filters.push(`sys_created_on>=${this.filterCreatedAtDate}`);
56
+ }
57
+ if (this.filterUpdatedAtDate) {
58
+ filters.push(`sys_updated_on>=${this.filterUpdatedAtDate}`);
59
+ }
60
+ if (this.filterActive !== undefined) {
61
+ filters.push(`active=${this.filterActive}`);
62
+ }
63
+ query = filters.join("^");
64
+ }
65
+
66
+ // Get tables
67
+ const tables = await this.servicenow.getTableRecords({
68
+ $,
69
+ table: "sys_db_object",
70
+ params: {
71
+ sysparm_query: query,
72
+ },
73
+ });
74
+
75
+ // Poll tables to check if they are accessible to the user
76
+ const accessibleTables = (await Promise.allSettled(
77
+ tables.map((t) =>
78
+ this.servicenow
79
+ .getRecordCountsByField({
80
+ $,
81
+ table: t.name,
82
+ params: {
83
+ sysparm_count: true,
84
+ },
85
+ })
86
+ .then(() => t)),
87
+ ))
88
+ .filter((r) => r.status === "fulfilled")
89
+ .map((r) => r.value)
90
+ .slice(0, this.limit);
91
+
92
+ $.export("$summary", `Successfully retrieved ${accessibleTables.length} table${accessibleTables.length === 1
93
+ ? ""
94
+ : "s"}`);
95
+ return accessibleTables;
96
+ },
97
+ };
@@ -5,7 +5,7 @@ export default {
5
5
  key: "servicenow-update-table-record",
6
6
  name: "Update Table Record",
7
7
  description: "Updates the specified record with the name-value pairs included in the request body. [See the documentation](https://www.servicenow.com/docs/bundle/zurich-api-reference/page/integrate/inbound-rest/concept/c_TableAPI.html#title_table-PATCH)",
8
- version: "1.0.2",
8
+ version: "1.0.3",
9
9
  annotations: {
10
10
  destructiveHint: true,
11
11
  openWorldHint: true,
@@ -24,6 +24,9 @@ export default {
24
24
  propDefinition: [
25
25
  servicenow,
26
26
  "recordId",
27
+ (c) => ({
28
+ table: c.table,
29
+ }),
27
30
  ],
28
31
  },
29
32
  updateFields: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/servicenow",
3
- "version": "0.8.2",
3
+ "version": "0.9.1",
4
4
  "description": "Pipedream ServiceNow Components",
5
5
  "main": "servicenow.app.mjs",
6
6
  "keywords": [
@@ -33,6 +33,26 @@ export default {
33
33
  type: "string",
34
34
  label: "Record ID",
35
35
  description: "The ID (`sys_id` field) of the record",
36
+ async options({
37
+ table, page,
38
+ }) {
39
+ if (!table) {
40
+ return [];
41
+ }
42
+ const response = await this.getTableRecords({
43
+ table,
44
+ params: {
45
+ sysparm_limit: 100,
46
+ sysparm_offset: page * 100,
47
+ },
48
+ });
49
+ return response.map(({
50
+ sys_id: value, label,
51
+ }) => ({
52
+ label: label || value,
53
+ value,
54
+ }));
55
+ },
36
56
  },
37
57
  responseDataFormat: {
38
58
  label: "Response Data Format",