zapier-platform-core 17.7.2 → 17.8.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zapier-platform-core",
3
- "version": "17.7.2",
3
+ "version": "17.8.0",
4
4
  "description": "The core SDK for CLI apps in the Zapier Developer Platform.",
5
5
  "repository": "zapier/zapier-platform",
6
6
  "homepage": "https://platform.zapier.com/",
@@ -63,7 +63,7 @@
63
63
  "node-fetch": "2.7.0",
64
64
  "oauth-sign": "0.9.0",
65
65
  "semver": "7.7.1",
66
- "zapier-platform-schema": "17.7.2"
66
+ "zapier-platform-schema": "17.8.0"
67
67
  },
68
68
  "devDependencies": {
69
69
  "@types/node-fetch": "^2.6.11",
@@ -33,10 +33,11 @@ const searchIsArrayOrEnvelope = {
33
33
  }
34
34
  if (
35
35
  !_.isString(results.paging_token) &&
36
- !_.isNull(results.paging_token)
36
+ !_.isNull(results.paging_token) &&
37
+ !_.isUndefined(results.paging_token)
37
38
  ) {
38
39
  return [
39
- `"paging_token" must be a string or null, got: ${typeof results.paging_token}`,
40
+ `"paging_token" must be a string or null or undefined, got: ${typeof results.paging_token}`,
40
41
  ];
41
42
  }
42
43
  // pass to array check below
@@ -171,7 +171,7 @@ export type CreatePerformGet<
171
171
  *
172
172
  * When `canPaginate` is true for the search, the object shape is required.
173
173
  */
174
- type SearchResult<T> = T[] | { results: T[]; paging_token: string };
174
+ type SearchResult<T> = T[] | { results: T[]; paging_token: string | null | undefined };
175
175
 
176
176
  /**
177
177
  * Search for objects on a partner API.
@@ -1,5 +1,5 @@
1
1
  import { expectAssignable, expectType } from 'tsd';
2
- import type { PollingTriggerPerform } from './functions';
2
+ import type { PollingTriggerPerform, SearchPerform } from './functions';
3
3
  import { Bundle, ZObject } from './custom';
4
4
  import { InferInputData } from './inputs';
5
5
  import { defineInputFields } from './typeHelpers';
@@ -62,3 +62,73 @@ expectType<
62
62
  bundle: Bundle<{ key1: string; key2?: number | undefined }>,
63
63
  ) => Promise<{ id: string; name: string }[]>
64
64
  >(simplePerformWithInputFieldsAndAutomaticInference);
65
+
66
+ //
67
+ // SearchResult<T> and SearchPerform tests
68
+ //
69
+
70
+ // Test SearchResult<T> with simple array return
71
+ const simpleSearchPerform = (async (z, bundle) => {
72
+ return [{ id: '1', name: 'test' }];
73
+ }) satisfies SearchPerform;
74
+
75
+ expectAssignable<SearchPerform<{}, { id: string; name: string }>>(
76
+ simpleSearchPerform,
77
+ );
78
+
79
+ // Test SearchResult<T> with paginated object return
80
+ const paginatedSearchPerform = (async (z, bundle) => {
81
+ return {
82
+ results: [{ id: '1', name: 'test' }],
83
+ paging_token: 'next-page-token',
84
+ };
85
+ }) satisfies SearchPerform;
86
+
87
+ expectAssignable<SearchPerform<{}, { id: string; name: string }>>(
88
+ paginatedSearchPerform,
89
+ );
90
+
91
+ // Test SearchResult<T> with null paging_token
92
+ const nullPagingTokenSearchPerform = (async (z, bundle) => {
93
+ return {
94
+ results: [{ id: '1', name: 'test' }],
95
+ paging_token: null,
96
+ };
97
+ }) satisfies SearchPerform;
98
+
99
+ expectAssignable<SearchPerform<{}, { id: string; name: string }>>(
100
+ nullPagingTokenSearchPerform,
101
+ );
102
+
103
+ // Test SearchResult<T> with undefined paging_token
104
+ const undefinedPagingTokenSearchPerform = (async (z, bundle) => {
105
+ return {
106
+ results: [{ id: '1', name: 'test' }],
107
+ paging_token: undefined,
108
+ };
109
+ }) satisfies SearchPerform;
110
+
111
+ expectAssignable<SearchPerform<{}, { id: string; name: string }>>(
112
+ undefinedPagingTokenSearchPerform,
113
+ );
114
+
115
+ // Test SearchResult<T> with empty results array
116
+ const emptyResultsSearchPerform = (async (z, bundle) => {
117
+ return {
118
+ results: [],
119
+ paging_token: 'next-page-token',
120
+ };
121
+ }) satisfies SearchPerform;
122
+
123
+ expectAssignable<SearchPerform<{}, { id: string; name: string }>>(
124
+ emptyResultsSearchPerform,
125
+ );
126
+
127
+ // Test SearchResult<T> with empty array return
128
+ const emptyArraySearchPerform = (async (z, bundle) => {
129
+ return [];
130
+ }) satisfies SearchPerform;
131
+
132
+ expectAssignable<SearchPerform<{}, { id: string; name: string }>>(
133
+ emptyArraySearchPerform,
134
+ );