import * as wmill from "windmill-client";
import createClient, { type Middleware } from "openapi-fetch";
type Nextcloud = {
  baseUrl: string,
  password: string,
  username: string
};
export async function main(
  ncResource: Nextcloud,
  userId: string | null = null,
  rowId: number,
  columnId: number,
  value: string,
  useAppApiAuth: boolean = false,
) {
  const client = createClient<paths>({ baseUrl: ncResource.baseUrl });
  const authMiddleware: Middleware = {
    async onRequest({ request, options }) {
      // fetch token, if it doesn’t exist
      // add Authorization header to every request
      request.headers.set("Authorization", `Basic ${btoa((ncResource.username) + ':' + ncResource.password)}`);
      if (useAppApiAuth) {
        request.headers.set("AA-VERSION", ncResource.aa_version,);
        request.headers.set("EX-APP-ID", ncResource.app_id,);
        request.headers.set("EX-APP-VERSION", ncResource.app_version,);
        request.headers.set("AUTHORIZATION-APP-API", btoa(
          `${userId || ncResource.username}:${ncResource.password}`,
        ));
      }
      return request;
    },
  };
  client.use(authMiddleware);
  try {
    const resp = await client.PUT("/index.php/apps/tables/api/1/rows/{rowId}", {
      params: {
        header: {
          "OCS-APIRequest": true,
        },
        query: {
          format: "json",
        },
        path: {
          rowId: rowId,
        },
      },
      body: {
        data: {
          [columnId]: value,
        }
      },
    });
    console.debug('RESPONSE', resp.data)
    return {
      [columnId]: value,
    }
  } catch (e) {
    console.debug('error', e)
  }
  return {}
} Submitted by nextcloud 284 days ago
import * as wmill from "windmill-client";
import createClient, { type Middleware } from "openapi-fetch";
type Nextcloud = {
  baseUrl: string,
  password: string,
  username: string
};
export async function main(
  ncResource: Nextcloud,
  userId: string | null = null,
  rowId: number,
  columnId: number,
  value: string,
  useAppApiAuth: boolean = false,
) {
  const client = createClient<paths>({ baseUrl: ncResource.baseUrl });
  const authMiddleware: Middleware = {
    async onRequest({ request, options }) {
      // fetch token, if it doesn’t exist
      // add Authorization header to every request
      request.headers.set("Authorization", `Basic ${btoa((userId || ncResource.username) + ':' + ncResource.password)}`);
      if (useAppApiAuth) {
        request.headers.set("AA-VERSION", "2.3.0",);
        request.headers.set("EX-APP-ID", "flow",);
        request.headers.set("EX-APP-VERSION", "1.0.1",);
        request.headers.set("AUTHORIZATION-APP-API", btoa(
          `${userId || ncResource.username}:${ncResource.password}`,
        ));
      }
      return request;
    },
  };
  client.use(authMiddleware);
  try {
    const resp = await client.PUT("/index.php/apps/tables/api/1/rows/{rowId}", {
      params: {
        header: {
          "OCS-APIRequest": true,
        },
        query: {
          format: "json",
        },
        path: {
          rowId: rowId,
        },
      },
      body: {
        data: {
          [columnId]: value,
        }
      },
    });
    console.debug('RESPONSE', resp.data)
    return {
      [columnId]: value,
    }
  } catch (e) {
    console.debug('error', e)
  }
  return {}
} Submitted by nextcloud 294 days ago
import * as wmill from "windmill-client";
import createClient, { type Middleware } from "openapi-fetch";
type Nextcloud = {
  baseUrl: string,
  password: string,
  username: string
};
export async function main(
  ncResource: Nextcloud,
  userId: string | null = null,
  rowId: number,
  columnId: number,
  value: string,
  useAppApiAuth: boolean = false,
) {
  const client = createClient<paths>({ baseUrl: ncResource.baseUrl });
  const authMiddleware: Middleware = {
    async onRequest({ request, options }) {
      // fetch token, if it doesn’t exist
      // add Authorization header to every request
      request.headers.set("Authorization", `Basic ${btoa((userId || ncResource.username) + ':' + ncResource.password)}`);
      if (useAppApiAuth) {
        request.headers.set("AA-VERSION", "2.3.0",);
        request.headers.set("EX-APP-ID", "flow",);
        request.headers.set("EX-APP-VERSION", "1.0.1",);
        request.headers.set("AUTHORIZATION-APP-API", btoa(
          `${userId || ncResource.username}:${ncResource.password}`,
        ));
      }
      return request;
    },
  };
  client.use(authMiddleware);
  try {
    const resp = await client.PUT("/index.php/apps/tables/api/1/rows/{rowId}", {
      params: {
        header: {
          "OCS-APIRequest": true,
        },
        query: {
          format: "json",
        },
        path: {
          rowId: rowId,
        },
      },
      body: {
        data: {
          [columnId]: value,
        }
      },
    });
    console.debug('RESPONSE', resp.data)
    return {
      [columnId]: value,
    }
  } catch (e) {
    console.debug('error', e)
  }
  return {}
} Submitted by nextcloud 294 days ago
import * as wmill from "windmill-client";
import createClient, { type Middleware } from "openapi-fetch";
export async function main(
  ncResource: Nextcloud,
  userId: string | null = null,
  rowId: number,
  columnId: number,
  value: string,
  useAppApiAuth: boolean = false,
) {
  const client = createClient<paths>({ baseUrl: ncResource.baseUrl });
  const authMiddleware: Middleware = {
    async onRequest({ request, options }) {
      // fetch token, if it doesn’t exist
      // add Authorization header to every request
      request.headers.set("Authorization", `Basic ${btoa((userId || ncResource.username) + ':' + ncResource.password)}`);
      if (useAppApiAuth) {
        request.headers.set("AA-VERSION", "2.3.0",);
        request.headers.set("EX-APP-ID", "flow",);
        request.headers.set("EX-APP-VERSION", "1.0.1",);
        request.headers.set("AUTHORIZATION-APP-API", btoa(
          `${userId || ncResource.username}:${ncResource.password}`,
        ));
      }
      return request;
    },
  };
  client.use(authMiddleware);
  try {
    const resp = await client.PUT("/index.php/apps/tables/api/1/rows/{rowId}", {
      params: {
        header: {
          "OCS-APIRequest": true,
        },
        query: {
          format: "json",
        },
        path: {
          rowId: rowId,
        },
      },
      body: {
        data: {
          [columnId]: value,
        }
      },
    });
    console.debug('RESPONSE', resp.data)
    return {
      [columnId]: value,
    }
  } catch (e) {
    console.debug('error', e)
  }
  return {}
} Submitted by nextcloud 295 days ago
import * as wmill from "windmill-client";
import createClient, { type Middleware } from "openapi-fetch";
export async function main(
  nextcloudResource: string,
  userId: string | null = null,
  rowId: number,
  columnId: number,
  value: string,
  useAppApiAuth: boolean = false,
) {
  const ncResource = await wmill.getResource(
    nextcloudResource,
  );
  const client = createClient<paths>({ baseUrl: ncResource.baseUrl });
  const authMiddleware: Middleware = {
    async onRequest({ request, options }) {
      // fetch token, if it doesn’t exist
      // add Authorization header to every request
      request.headers.set("Authorization", `Basic ${btoa((userId || ncResource.username) + ':' + ncResource.password)}`);
      if (useAppApiAuth) {
        request.headers.set("AA-VERSION", "2.3.0",);
        request.headers.set("EX-APP-ID", "flow",);
        request.headers.set("EX-APP-VERSION", "1.0.1",);
        request.headers.set("AUTHORIZATION-APP-API", btoa(
          `${userId || ncResource.username}:${ncResource.password}`,
        ));
      }
      return request;
    },
  };
  client.use(authMiddleware);
  try {
    const resp = await client.PUT("/index.php/apps/tables/api/1/rows/{rowId}", {
      params: {
        header: {
          "OCS-APIRequest": true,
        },
        query: {
          format: "json",
        },
        path: {
          rowId: rowId,
        },
      },
      body: {
        data: {
          [columnId]: value,
        }
      },
    });
    console.debug('RESPONSE', resp.data)
    return {
      [columnId]: value,
    }
  } catch (e) {
    console.debug('error', e)
  }
  return {}
} Submitted by nextcloud 299 days ago