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

@simpleview/dam-client

v1.0.2

Published

Client for communicating with dam-kube

Downloads

7

Readme

dam-client

DAM (Digital Asset Management) client for accessing DAM resources.

Installation

npm install @simpleview/dam-client

Private Assets

The DAM supports the upload of private assets. As long as an asset is marked as private, it will not appear in any query unless the correct id of the asset is supplied in the query filter.

API

DamPrefix

DamPrefix can be loaded into sv-graphql-client GraphServer to use as a client library for managing assets. The DAM client requires authentication.

const { GraphServer } = require("@simpleview/sv-graphql-client");
const { AuthPrefix } = require("@simpleview/sv-auth-client");
const { DamPrefix } = require('@simpleview/dam-client');

const prefixes = [AuthPrefix, DamPrefix];

const server = new GraphServer({ graphUrl, prefixes });

assets

Queries for assets allowing sorting and filtering operations.

  • filter - Requires a dam_assets_filter defining assets to return.
  • fields - Requires an object defining the GraphQL fields to be returned from graph.
  • context - Requires an object with a valid auth token and the account_id of the platform the query should be run on.

Retrieve Private Asset

const supaSecretAsset = await server.dam.assets({
	{ filter : { id : '000000000000000000000001'} },
	{ `docs { asset_url }` },
	{ token, acct_id }
});

Retrieve Multiple Assets

const assetsPage2 = await server.dam.assets({
	{ filter : { }, options : { limit : 5, skip : 5, sort : { field : 'file_name' dir : 'asc' } } },
	{ `docs { asset_url }` },
	{ token, acct_id }
});

assets_upsert

Allows for creating new assets and updating existing assets.

  • input - Requires a DAM FileObject and accepts optional private boolean and id string.
  • fields - Requires an object defining the GraphQL fields to be returned from graph.
  • context - Requires an object with a valid auth token and the account_id of the platform the upsert should be run on.
const upsertResult = await server.dam.assets_upsert({
	{ fileObject },
	{ `success id` },
	{ token, acct_id }
});

assets_remove

Allows for the soft delete of assets from the DAM.

  • filter - Requires a dam_assets_remove_filter defining assets to remove.
  • fields - Requires an object defining the GraphQL fields to be returned from graph.
  • context - Requires an object with a valid auth token and the account_id of the platform the remove should be run on.
const upsertResult = await server.dam.assets_remove({
	{ id : '000000000000000000000001' },
	{ `success message` },
	{ token, acct_id }
});

convertFileToFileObject

Converts a browser's File into a DAM FileObject.

  • file - An object matching the Web File API.
const file = document.body.querySelector('[data-file-picker]').files[0];
const damFileObject = await server.dam.convertFileToFileObject({ file });

GraphQL Endpoints

This section is provided to provide additional information about the GraphQL endpoints. To see the input parameters and output of each endpoint, please view the Schema in the GraphQL Explorer at https://graphql.simpleviewinc.com/.

All GraphQL endpoints for the DAM require an auth bearer token and an account id

dam_query

assets

Returns an object containing an array of assets and a count of the assets found. Supports a filter for selecting specific assets and options for limiting the return.

{
	dam(acct_id: "1") {
		assets{ 
			count
			docs { 
				id
				asset_url
			}
		}
	}
}

dam_mutation

assets_remove

Requires a filter object and performs a soft delete on a matching assets in the system. Returns an object containing a success boolean and a message relating to the removal.

mutation {
	dam(acct_id: "1") { 
		assets_remove(
			filter : {
				id : "000000000000000000000001"
			}
		){
			success
			message
		}
	}
}

assets_upsert

Requires an dam_assets_upsert object and either inserts or updates an asset based on whether or not an existing id is provided.

	mutation {
	dam(acct_id: "1") { 
		assets_upsert(
			input : {
				id : "000000000000000000000001",
				file_name : "cutePuppyInPuddle.jpg",
				file_type : "image",
				cdn_id : "dam/clients/dam/kbrid7wjepu7ljc8n3sa" 
			}
		){
			success
			message
			doc {
				id
				acct_id
				asset_url
				file_name
			}
		}
	}
}

Development

  • Tests located in dam-kube
  • Publish - sudo npm run publish SEMVER

Additional Documentation