(
key: string,
pageNumber: number,
params?: Optional<Parameters<TResource["all"]>[0], "session">
)
| 105 | } |
| 106 | |
| 107 | async #allSinglePage( |
| 108 | key: string, |
| 109 | pageNumber: number, |
| 110 | params?: Optional<Parameters<TResource["all"]>[0], "session"> |
| 111 | ): AllReturnType<TResource> { |
| 112 | const { session, ...paramsWithoutSession } = params ?? {}; |
| 113 | |
| 114 | return this.runTask( |
| 115 | `${key}-page-${String(pageNumber)}`, |
| 116 | async (client, task, io) => { |
| 117 | const allResponse = await client.rest[this.resourceType].all( |
| 118 | this.#withSession(params ?? {}) |
| 119 | ); |
| 120 | |
| 121 | task.outputProperties = [ |
| 122 | { |
| 123 | label: `${this.resourceType}s`, |
| 124 | text: String(allResponse.data.length), |
| 125 | }, |
| 126 | ]; |
| 127 | |
| 128 | return { |
| 129 | data: serializeShopifyResource(allResponse.data) as Awaited< |
| 130 | AllReturnType<TResource> |
| 131 | >["data"], |
| 132 | pageInfo: allResponse.pageInfo, |
| 133 | }; |
| 134 | }, |
| 135 | { |
| 136 | name: `Get All ${this.resourceType}s`, |
| 137 | params: paramsWithoutSession, |
| 138 | properties: [ |
| 139 | { |
| 140 | label: "Page Number", |
| 141 | text: String(pageNumber), |
| 142 | }, |
| 143 | ], |
| 144 | } |
| 145 | ); |
| 146 | } |
| 147 | |
| 148 | /** |
| 149 | * Fetch all resources of a given type. |
no test coverage detected