Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@simpleview/dam-client

Package Overview
Dependencies
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@simpleview/dam-client

Client for communicating with dam-kube

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-89.29%
Maintainers
4
Weekly downloads
 
Created
Source

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 upsertResult = await server.dam.asssets({
	{ filter : { id : '000000000000000000000001', private: true } },
	{ `docs { asset_url }` },
	{ token, acct_id }
});
Retrieve Multiple Assets
const upsertResult = await server.dam.asssets({
	{ filter : { }, options : { limit : 5, skip : 1, 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 });

Performs a soft delete of an asset in the dam by id.

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

FAQs

Package last updated on 29 Apr 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc