architect / functions

AWS Lambda Node runtime helpers for Architect apps
https://arc.codes
163 stars 38 forks source link

Allow passing translateConfig to Dynamo client and doc client #542

Open bzang opened 1 year ago

bzang commented 1 year ago

Is your feature request related to a problem? Please describe. In certain situations I need to use the Dynamodb option to removeUndefinedValues . Currently it doesn't seem like we can pass these options in the arc.tables().

Describe the solution you'd like I'd like to be able to pass config parameters to the tables() call in order to pass these option to where the Client and DocClient are being instantiated. Maybe something like

const options = {
  docConfig: {
    marshallOptions: {
      convertEmptyValues: false,
      removeUndefinedValues: true,
      convertClassInstanceToMap: true,
    },
    unmarshallOptions: {
      wrapNumbers: true,
    }
  };

Describe alternatives you've considered If it set up my own Dynamo client instance instead of using the arc provided tables() call, users would still have problems because we'd lose the advantages of the main arc functions package.

hungds99 commented 9 months ago

I have the same issues. I want to custom endpoint and region for arc.tables().

ryanblock commented 9 months ago

@bzang @hungds99 a big update is about to land in Arc Functions: 8.0 drops the AWS SDK (and stock DynamoDB client) in favor of aws-lite. More details:

For whatever it's worth, under the hood aws-lite uses the AWS-flavored JSON marshall/unmarshall utilities. Can you present a use case scenario we can look at within the aws-lite implementation? Specifically: some code / data that isn't currently working that should work?

hungds99 commented 9 months ago

hi @ryanblock , I am try to using aws-lite for my Shopify App Remix project but I got this issue : Property 'DynamoDB' does not exist on type 'AwsLiteClient'.

import AwsLite from '@aws-lite/client';

const awsLiteClient = async () => {
  const aws = await AwsLite({ region: 'us-west-1' });

  // Easily interact with the AWS services your application relies on
  await aws.DynamoDB.PutItem({
    TableName: '$table-name',
    Item: {
      // AWS-lite automatically de/serializes DynamoDB JSON
      pk: '$item-key',
      data: {
        ok: true,
        hi: 'friends',
      },
    },
  });
};
ryanblock commented 9 months ago

Did you install @aws-lite/dynamodb?

hungds99 commented 9 months ago

@ryanblock Yes, my dependencies:

 "@aws-lite/client": "^0.14.0",
 "@aws-lite/dynamodb": "^0.3.1",
 "@aws-lite/dynamodb-types": "^0.3.1",
ryanblock commented 9 months ago

I wonder if that's because Remix is bundling things – I'd suggest getting started without bundling so you can isolate issues as you pick up the new SDK. From there you may need to specify a path to the DynamoDB plugin with the plugins configuration (see: https://aws-lite.org/configuration#general-config).

ryanblock commented 9 months ago

Actually, I may have also misread your issue above. So the DynamoDB call works ok, it's the types that are broken? If so, can you open an issue in the aws-lite project with steps to reproduce (including code editor, version, etc.)?

hungds99 commented 9 months ago

@ryanblock Sure, I have another question. Currently, I am using arc for deployment to AWS but I see the table name have specific ID like this BAppAdminRemixProduction-ShopSessionsTable-359Z4PXN3ZOU. Can I use aws-lite dynamodb interact with table in arc deploy ?