npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@amplience/image-studio-sdk

v0.3.0

Published

Image Studio SDK

Downloads

100

Readme

@amplience/image-studio-sdk

Official SDK for embedding Amplience Image Studio

This SDK is designed to help embed the Amplience Image Studio into business admin interfaces, allowing merchants, marketers and authors to generate images as part of their existing tools and workflow.

Installation

Using npm:

npm install @amplience/image-studio-sdk --save

Usage

ES6:

import { AmplienceImageStudio } from '@amplience/image-studio-sdk';

const sdk = new AmplienceImageStudio();

CommonJS:

const { AmplienceImageStudio } = require('@amplience/image-studio-sdk');

const sdk = new AmplienceImageStudio();

Creating a global instance of AmplienceImageStudio is advised against, and a new one should be created for each interaction due to shared promise management you may get expected results if you make asynchronous interactions with the same instance.

AmplienceImageStudioOptions

When creating an AmplienceImageStudio instance, the constructor takes an AmplienceImageStudioOptions object. This defines several options for customizing the behaviour of the studio:

| Key | Description | Default | Optional | |:----------|:-------------|:-:|:-:| | domain | base domain for your image-studio deployment | - | No | | sdkMetadataOverride | object containing behavioural overrides for image-studio SDKMetadata | {} | Yes | | windowTarget | window.open() target override, please see MDN | '_blank' | Yes | | windowFeatures | window.open() windowFeatures override, please see MDN | '' | Yes |

SDKMetadata

This SDK controls certain behaviours within image-studio through optional enablement flags.

Failing to submit an option to image-studio will not result in any bad behaviour. Image-Studio determines and controls the default behaviour of every option, however the structure and options available are controlled by this SDK.

| Option | Description | Default | |:----------|:-|:-:| | allowImageSave | allows content to be saved back to the SDK | false | | allowLogout | allows users to logout | true | | allowCreate | allows users to create new content | true |

Image Studio Actions

Each action contains a default set of behavioural options:

Note that not every option is supplied by default.

| Action | Options | |:----------|:-| | editImages | allowImageSave: trueallowLogout: falseallowCreate: false | | launch | allowImageSave: falseallowLogout: trueallowCreate: true |

The user can override the default action behaviours by adding the relevant options to the sdkMetadataOverride member foun within AmplienceImageStudioOptions

Edit Images

Image Studio expects an array of images for editing, once the user has editied the images and clicked 'Save Image', the resultant image will be returned within the response object and the Image Studio window will be closed.

Note: Image Studio currently only uses the first image you submit via this call

const sdk = new AmplienceImageStudio({
    domain: IMAGE_STUDIO_DOMAIN,
});
const response = await sdk.editImages([{
    url: 'https://url-to-your-image',
    name: 'image-name',
    mimeType: 'image/jpeg', 
}]);

if(response.reason == ImageStudioReason.IMAGE) {
    console.log(response.image);
    // Example Image Response
    // {
    //     url: 'https://url-to-your-updated-image',
    //     name: 'updated-image-name',
    //     mimeType: 'image/jpeg', 
    // }
}

Launch

Launches an Image Studio session standalone, which allows the user to select their own image for editing. Users are not able to save content back to their application and will only be able to download their creations locally.

const sdk = new AmplienceImageStudio({
    domain: IMAGE_STUDIO_DOMAIN,
});
const response = await sdk.launch();

if(response.reason == ImageStudioReason.CLOSED) {
    console.log("Success");
}

Releases

TLDR auto will perform automatic canary builds on push and the full release (including version bumping) during PR merge.

This project uses auto for the release process, a conventional commits plugin handles version bumping based on the commit history. Docs

The release process follows the configuration HERE

We have also included another plugin, protected-branch which works around the fact this repo contains branch protection on main. At the time of writing, this plugin isnot documented but the code can be found HERE

This project contains a Ruleset for main, with the following options enabled:

- Restrict creations
- restrict deletions
- block force pushes
- Requires a pull request before merging
    - approvals: 1
    - dismiss stale pull requests
    - require review from code owners
    - require conversation resolution before merging

In order to get around CODEOWNERS being required, we have followed the recommendations for adding @amplience/automation team as owners to package.json, package-lock.json and CHANGELOG.md - this allows auto to modify these at release time. The amp automation team also requires admin access to this github repo (repo -> settings -> collaborators and teams)

The release process requires a fine grained PAT token to perform the release process: this has been shared to this public repo through secrets.GH_PUBLIC_REPO_CONTENTS_ACCESS, the underlying token this references has been scoped to public repo's only. If this pattern is to be used against another project in future, and this is private, please add a PRIVATE variant of this PAT to cover private repos - otherwise add your project to the existing PAT token list of repositories. The purpose of GH_PUBLIC_REPO_CONTENTS_ACCESS secret is to cover only public repositories.

The initial part of the release process (checkouts, builds and package write) is controlled by the auto generate GH_TOKEN user, we have scoped this user with the correct permissions as found under permissions: within release.yml

The GH_PUBLIC_REPO_CONTENTS_ACCESS PAT is specificially used for the latter release portion (ie non-canary builds) and this user requires special privileges to perform package writes, changelog updates and commit's back to the repo itself (this is done via PR). At the time of writing the repository persmissions (through fine grained PAT) are:

- actions: read and write
- contents: read and write
- pull-requests: read and write
- issues: read
- metadata: read

License

This software is licensed under the Apache License, Version 2.0,

Copyright 2024 Amplience

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.