@pipedream/servicenow 0.8.2 → 0.9.0

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.
@@ -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.1",
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
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pipedream/servicenow",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "description": "Pipedream ServiceNow Components",
5
5
  "main": "servicenow.app.mjs",
6
6
  "keywords": [