@cfxlabsinc/b2b-services
    Preparing search index...
    Index
    db: B2bDatabase
    s3Client: S3Client
    instance: (...args: []) => TransactionMetadataFileService = ...

    The process default: built from each dependency's own instance().

    • Attach a request-owned (already promoted) object to a transaction. The record points at the request's key, so get serves it with no second copy. A retry returns the existing record.

      Parameters

      • __namedParameters: {
            customerId: string;
            fileName: string;
            requestId: string;
            s3ObjectKey: string;
            transactionId: string;
        }

      Returns Promise<
          | {
              ok: true;
              value: { created: boolean; file: TransactionMetadataFile };
          }
          | { error: ServiceError; ok: false },
      >

    • Create a new transaction metadata file record in the database linked to an S3 object. This method first checks if the S3 object exists before creating the record. If the S3 object does not exist, an error is thrown.

      Parameters

      • customerId: {
            customerId: string;
            fileName: string;
            s3ObjectKey: string;
            transactionId: string;
        }

        The ID of the logged in customer.

      Returns Promise<{ ok: true; value: TransactionMetadataFile }>

      A promise that resolves to the created transaction metadata file record.

      Error if the S3 object does not exist.

    • Copy file object from Staging S3 bucket to Transaction files S3 bucket. Create a new transaction metadata file record in the database linked to the S3 file object. This method first checks if the S3 object exists before creating the record. If the S3 object does not exist, an error is thrown.

      Parameters

      • customerId: {
            customerId: string;
            fileName: string;
            stagingS3ObjectKey: string;
            transactionId: string;
        }

        The ID of the logged in customer.

      Returns Promise<
          | { ok: true; value: TransactionMetadataFile }
          | { error: ServiceError; ok: false },
      >

      A promise that resolves to the created transaction metadata file record.

      Error if the S3 object does not exist.

    • Parameters

      • __namedParameters: { customerId: string; id: string }

      Returns Promise<
          {
              ok: true;
              value: | Omit<
                  {
                      createdAt: Date;
                      customerExternalId: string;
                      customerId: number;
                      data: { awsS3Path: string; fileName: string };
                      externalId: string;
                      id: number;
                      status: "ACTIVE" | "DELETED";
                      transactionId: string;
                      updatedAt: Date;
                  },
                  "id"
                  | "externalId"
                  | "data"
                  | "customerId"
                  | "customerExternalId",
              > & { awsS3Path: string; fileName: string } & { id: string } & {
                  url: string;
              }
              | null;
          },
      >

    • Parameters

      • __namedParameters: {
            customerId: string;
            fileName: string;
            fileSize: number;
            fileType: string;
            quoteId: string;
        }

      Returns Promise<
          | { error: ServiceError; ok: false }
          | { ok: true; value: { s3ObjectKey: string; url: string } },
      >

    • Get a pre-signed URL that can be used to upload a file to S3. The URL is short-lived (2mins) and can be used to upload a file with the specified file name, type, and size.

      Parameters

      • customerId: {
            customerId: string;
            fileName: string;
            fileSize: number;
            fileType: string;
            transactionId: string;
        }

        The ID of the logged in customer.

      Returns Promise<
          | { ok: true; value: { s3ObjectKey: string; url: string } }
          | { error: ServiceError; ok: false },
      >

      A promise that resolves to an object containing the signed URL and S3 Object key.

      ServiceError if the file type is not accepted or the file size exceeds the limit.

    • Parameters

      • __namedParameters: { customerId: string; fileName: string; s3ObjectKey: string }

      Returns Promise<
          | { error: ServiceError; ok: false }
          | { ok: true; value: { url: string } },
      >

    • Copy a staging object to a key owned by an approval request, so it outlives the staging bucket's one-day sweep. No database row: the key and file name go into the request's metadata, and execution later attaches them with attachRequestFile. Run it outside any database transaction. Promoted files stay when a request ends DECLINED or CANCELLED, so Make again can reuse them.

      Parameters

      • __namedParameters: {
            customerId: string;
            fileName: string;
            requestId: string;
            stagingS3ObjectKey: string;
        }

      Returns Promise<
          | { error: ServiceError; ok: false }
          | { ok: true; value: { fileName: string; s3ObjectKey: string } },
      >

    • Parameters

      • __namedParameters: {
            customerId: string;
            fileNameLike?: string;
            ids?: string[];
            page?: number;
            pageSize?: number;
            transactionIds?: string[];
        }

      Returns Promise<
          {
              ok: true;
              value: {
                  hasNext: boolean;
                  items: TransactionMetadataFile[];
                  total: number;
              };
          },
      >