Giter Site home page Giter Site logo

adobe / aio-sdk Goto Github PK

View Code? Open in Web Editor NEW
9.0 22.0 12.0 90 KB

Module that contains all the Adobe I/O SDKs

License: Apache License 2.0

JavaScript 100.00%
adobe aio-sdk adobe-target adobe-campaign-standard adobe-analytics adobe-io adobe-audience-manager adobe-experience-platform adobe-experience-cloud adobeio

aio-sdk's Introduction

@adobe/aio-sdk

Version Downloads/week Node.js CI License Codecov Coverage

This is the Adobe I/O SDK. This contains:

SDK Health

The module can be added to your project with:

npm install @adobe/aio-sdk --save

Here is a snippet:

const adobeIOSdk = require('@adobe/aio-sdk')
// OR ...
const { Core, State, Files, Target, Analytics, CampaignStandard, CustomerProfile, Events } = require('@adobe/aio-sdk')

// Core example
// set a config value using the Core SDK Config module
Core.Config.set('my.token', 1234)

// State example
// init when env vars __OW_API_KEY and __OW_NAMESPACE are set (e.g. when running in an OpenWhisk action)
const state = await State.init()
// get a value from the state store
const { value, expiration } = await state.get('key')
 
// Files example
// init when env vars __OW_API_KEY and __OW_NAMESPACE are set (e.g. when running in an OpenWhisk action)
const files = await Files.init()
// write private file
await files.write('mydir/myfile.txt', 'some private content')

// Target example
const targetClient = await Target.init('<tenant>', 'x-api-key', '<valid auth token>')
const activities = await targetClient.getActivities({limit:5, offset:0})

// Analytics example
const analyticsClient = await Analytics.init('<companyID>', 'x-api-key', '<valid auth token>')
const collections = await analyticsClient.getCollections({limit:5, page:0})

// Campaign Standard example
const campaignStandardClient = await CampaignStandard.init('<tenant>', 'x-api-key', '<valid auth token>')
const profiles = await campaignStandardClient.getAllProfiles({ filters: [ 'byCRMId' ], hasCustomFilter: true })

// Customer Profile example
const customerProfileClient = await CustomerProfile.init('<tenant>', '<imsOrgId>', 'x-api-key', '<valid auth token>', '[sandbox]')
const profileParams = {
      entityId: '<entityId>',
      entityIdNS: '<entityIdNS>'
    }
const customerProfile = await customerProfileClient.getProfile(profileParams)

// Adobe I/O Events sample
const eventsSDKClient = await Events.init('<orgId>', '<api-key>', '<valid JWT token>', '<http options>')
const eventsProviders = await eventsSDKClient.getAllProviders('<consumerOrgId>')

Explore

goto API

Contributing

Contributions are welcomed! Read the Contributing Guide for more information.

Licensing

This project is licensed under the Apache V2 License. See LICENSE for more information.

aio-sdk's People

Contributors

amulyakashyap09 avatar chiarabdy avatar dependabot[bot] avatar greenkeeper[bot] avatar himavanth avatar meryllblanchet avatar michaelgoberling avatar moritzraho avatar purplecabbage avatar sandeep-paliwal avatar sangeetha5491 avatar shazron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aio-sdk's Issues

Error deploying action Returned HTTP 503 (Service Unavailable) --> "Response Missing Error Message."

In the setup where an action index.js and its dependencies is zipped with :

const rtLib = require('@adobe/aio-lib-runtime')

rtLib.utils.zip(
  'dist/application/actions/pages-temp',
  'dist/application/actions/pages.zip'
)

adding const { Core } = require('@adobe/aio-sdk'); to the action and deploying it to runtime with aio app deploy --no-web-assets --no-build fails with the following error:

 ›   Error: PUT https://adobeioruntime.net/api/v1/namespaces/mynamespace/actions/actions/pages Returned HTTP 503 (Service Unavailable) --> "Response Missing Error Message."

Issue with node-fetch in aio-lib-files affecting other modules

When I try to use the CampaignStandard sdk in this sdk, I get an error:
TypeError: Request with GET/HEAD method cannot have body

I have narrowed it down to this line:

const Files = require('@adobe/aio-lib-files')

If this line is commented out (and the corresponding exports object reference), I can use CampaignStandard SDK properly. The error appears to be in the node-fetch module used by aio-lib-files: https://www.npmjs.com/package/node-fetch at https://github.com/bitinn/node-fetch/blob/bf8b4e8db350ec76dbb9236620f774fcc21b8c12/src/request.js#L77

CampaignStandard uses cross-fetch which uses node-fetch 2.6.0, while aio-lib-files uses ^2.6.0. The latest version of node-fetch is 2.6.0

cc @meryllblanchet @moritzraho @purplecabbage

Validate Files api major version

The latest released version of aio-lib-files has breaking changes

  • evaluate it as part of a new major for the sdk
  • check that there are no issues between aio-lib-files + aio-lib-state which use differing versions of azure-api client

Evaluate lib size for all packages used in serverless

In making the aio-lib-env library work with webpack and serverless actions I noticed some size issues.
This is not a reflection of aio-lib-env, just the way npm packages work ...
aio-lib-env is used as an example because it is probably our smallest module, 74 LOC including license header
BundlePhobia reports it has a minified size of 348.4 kB [1]

Adding to an action

a simple action with a dependency on node-fetch and nothing else:

du -sh dist/actions/list-temp 
384K	dist/actions/list-temp
du -sh dist/actions/list.zip       
180K	dist/actions/list.zip

add + build

const { getCliEnv, DEFAULT_ENV } = require('@adobe/aio-lib-env') and console.log('getCliEnv => ', getCliEnv())

du -sh dist/actions/list-temp 
1.3M	dist/actions/list-temp
du -sh dist/actions/list.zip 
388K	dist/actions/list.zip

Most of this is probably the logging lib, which includes winston, ... but the simple fact that this lib is so small really shows the point.

An action that uses aio-sdk only

const { Core } = require('@adobe/aio-sdk')

du -sh dist/actions/list-temp 
6.5M	dist/actions/list-temp
du -sh dist/actions/list.zip 
1.4M	dist/actions/list.zip

Adding back @adobe/aio-lib-env has no effect if @adobe/aio-sdk is already there ...

du -sh dist/actions/list-temp 
6.5M	dist/actions/list-temp
du -sh dist/actions/list.zip 
1.4M	dist/actions/list.zip

1 : bundlephobia aio-lib-env

Cannot get the latest release version when running npm install

Expected Behaviour

Running the following commands should get the latest release version (4.0.0)

npm install @adobe/aio-sdk --save

or

npm install @adobe/aio-sdk@latest --save

Actual Behaviour

Instead, the 3.0.0 is installed.

Steps to Reproduce

npm uninstall @adobe/aio-sdk --save

and run again, the npm install command.

I've been working with Adobe App Builder and here the package list and versions,

"dependencies": {
    "@adobe/exc-app": "^0.2.21",
    "@adobe/react-spectrum": "^3.4.0",
    "@spectrum-icons/workflow": "^3.2.0",
    "cloudevents": "^4.0.2",
    "core-js": "^3.6.4",
    "flagsmith-nodejs": "^2.3.0",
    "node-fetch": "^2.6.0",
    "perf_hooks": "0.0.1",
    "pretty-ms": "^8.0.0",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-error-boundary": "^1.2.5",
    "react-router-dom": "^5.2.0",
    "regenerator-runtime": "^0.13.5",
    "uuid": "^8.0.0"
  },
  "devDependencies": {
    "@babel/core": "^7.8.7",
    "@babel/plugin-transform-react-jsx": "^7.8.3",
    "@babel/polyfill": "^7.8.7",
    "@babel/preset-env": "^7.8.7",
    "@openwhisk/wskdebug": "^1.3.0",
    "@types/jest": "^28.1.4",
    "@types/node": "^18.0.1",
    "@types/node-fetch": "^2.6.2",
    "@typescript-eslint/eslint-plugin": "^5.30.5",
    "@typescript-eslint/parser": "^5.30.5",
    "eslint": "^8.19.0",
    "jest": "^27.2.4",
    "npm-run-all": "^4.1.5",
    "prettier": "^2.7.1",
    "shx": "^0.3.4",
    "ts-jest": "^28.0.5",
    "typescript": "^4.7.4"
  },

Node: v14.18.2
NPM: 6.14.15

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.