MCPcopy
hub / github.com/qawolf/cli / createPlatformClient

Function createPlatformClient

src/shell/platform/createPlatformClient.ts:56–149  ·  view source on GitHub ↗
(
  apiKey: string,
  deps: Deps,
)

Source from the content-addressed store, hash-verified

54const requestBackoffMs = [500, 1500] as const;
55
56export function createPlatformClient(
57 apiKey: string,
58 deps: Deps,
59): PlatformClient {
60 const trpc = createTrpcClient(apiKey, deps);
61 const fs = deps.fs ?? makeDefaultFs();
62
63 async function getFlowsBundleUrlImpl(
64 envId: string,
65 ): Promise<PlatformResult<{ signedUrl: string }>> {
66 const result = await requestWithRetry({
67 call: () =>
68 // gitwolf is the platform's flows-bundle tRPC router.
69 trpc.mutation(
70 "gitwolf.getFlowsBundleUrl",
71 { environmentId: envId },
72 flowsBundleResponseSchema,
73 ),
74 backoffMs: requestBackoffMs,
75 describe: (err) => describeRequestError(err, deps.baseUrl),
76 sleep: deps.sleep,
77 });
78 if (!result.ok) return result;
79 return { ok: true, value: { signedUrl: result.value.url } };
80 }
81
82 return {
83 async getIdentity() {
84 return requestWithRetry({
85 call: () => getIdentity(apiKey, deps),
86 backoffMs: requestBackoffMs,
87 describe: describeIdentityError,
88 sleep: deps.sleep,
89 });
90 },
91
92 async getRemoteFlows() {
93 return requestWithRetry({
94 call: () => getRemoteFlows(apiKey, deps),
95 backoffMs: requestBackoffMs,
96 describe: (err) => describeRequestError(err, deps.baseUrl, "flows"),
97 sleep: deps.sleep,
98 });
99 },
100
101 getFlowsBundleUrl: getFlowsBundleUrlImpl,
102
103 callPublicApi: makeCallPublicApiMethod(trpc, deps, requestBackoffMs),
104
105 async getEnvVars(envId) {
106 const result = await requestWithRetry({
107 call: () =>
108 trpc.query(
109 "environment.getEnvironmentWithVariables",
110 { id: envId },
111 environmentWithVariablesResponseSchema,
112 ),
113 backoffMs: requestBackoffMs,

Calls 3

createTrpcClientFunction · 0.85
makeDefaultFsFunction · 0.85
makeCallPublicApiMethodFunction · 0.85

Tested by

no test coverage detected