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

@dynatrace-sdk/client-state

v1.5.0

Published

Provides key-value storage for apps so that app developers can persist and get small chunks of state in the context of their app.

Downloads

778

Readme

@dynatrace-sdk/client-state

npm License

Overview

Provides key-value storage for apps so that app developers can persist and get small chunks of state in the context of their app.

States can either be stored in the context of an app (= app states) or in the context of an app and user (= user app states).

  • States stored per app can be read by every user of the app.
  • States stored per app and user can only be read and updated by the user who originally set that state. Please visit the Dynatrace Developer to learn more about app states and user app states.

Installation

npm install @dynatrace-sdk/client-state

Getting help

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

API reference

Full API reference for the latest version of the SDK is also available at the Dynatrace Developer.

stateClient

import { stateClient } from '@dynatrace-sdk/client-state';

deleteAppState

Deletes app state

Required scope: state:app-states:delete

Parameters

| Name | Type | Description | | --- | --- | --- | |config.key*required|string|Specify the key of the state |

import { stateClient } from "@dynatrace-sdk/client-state";

const data = await stateClient.deleteAppState({
  key: "some-key",
});

deleteAppStates

Delete all app states

Required scope: state:app-states:delete

Deletes all app states for an app to reset the app into a clean state.

import { stateClient } from "@dynatrace-sdk/client-state";

const data = await stateClient.deleteAppStates();

deleteUserAppState

Delete user app state

Required scope: state:user-app-states:delete

Parameters

| Name | Type | Description | | --- | --- | --- | |config.key*required|string|Specify the key of the state |

import { stateClient } from "@dynatrace-sdk/client-state";

const data = await stateClient.deleteUserAppState({
  key: "some-key",
});

deleteUserAppStates

Delete all user app states

Required scope: state:user-app-states:delete

Deletes all user app states for the calling user and app.

import { stateClient } from "@dynatrace-sdk/client-state";

const data = await stateClient.deleteUserAppStates();

getAppState

Gets app state

Required scope: state:app-states:read

Parameters

| Name | Type | Description | | --- | --- | --- | |config.key*required|string|Specify the key of the state |

Returns

The app state

import { stateClient } from "@dynatrace-sdk/client-state";

const data = await stateClient.getAppState({
  key: "some-key",
});

getAppStates

List app states

Required scope: state:app-states:read

Lists app states. By default, only provides property key per state. Use add-fields parameter to include more fields and the filter parameter to narrow down the returned states.

Parameters

| Name | Type | Description | | --- | --- | --- | |config.addFields|string|Provide a comma separated list of additional properties to be included in the response. | |config.filter|string|The filter parameter for filtering the set of returned resources If this parameter is omitted, no filtering is applied and all states will be returned. Filtering by string type parameters key, modificationInfo.lastModifiedBy when using one of the operators contains, starts-with and ends-with is case insensitive. When using the operators =and !=, filtering is case sensitive. The following fields are legal filtering parameters - any other field names will result in a HTTP 400 response: key, supported operators: =, !=, contains, starts-with, ends-with: modificationInfo.lastModifiedTime, supported operators: =, !=, <, <=, >, >= modificationInfo.lastModifiedBy, supported operators: =, !=, contains, starts-with, ends-with validUntilTime, supported operators: =, !=, <, <=, >, >= The following constraints apply: Field names are case-sensitive. Conditions can be connected via operators and and or. A single condition can be negated by not. Strings must be enclosed in single quotes. e.g. key contains 'my-string' Single quotes within a string must be escaped with a backslash: e.g. key starts-with 'it\'s a string' Maximum nesting depth (via brackets) is 2. Maximum length is 256 characters. Examples: key starts-with 'game-' modificationInfo.lastModifiedTime >= '2022-07-01T00:10:05.000Z' and not (key contains 'new') |

Returns

The list of app states

import { stateClient } from "@dynatrace-sdk/client-state";

const data = await stateClient.getAppStates();

getUserAppState

Get user app state

Required scope: state:user-app-states:read

Parameters

| Name | Type | Description | | --- | --- | --- | |config.key*required|string|Specify the key of the state |

Returns

The user app state

import { stateClient } from "@dynatrace-sdk/client-state";

const data = await stateClient.getUserAppState({
  key: "some-key",
});

getUserAppStates

List user app states

Required scope: state:user-app-states:read

Lists user app states. By default, only provides property key per state. Use add-fields parameter to include more fields and the filter parameter to narrow down the returned states

Parameters

| Name | Type | Description | | --- | --- | --- | |config.addFields|string|Provide a comma separated list of additional properties to be included in the response. | |config.filter|string|The filter parameter for filtering the set of returned resources If this parameter is omitted, no filtering is applied and all states will be returned. Filtering by string type parameters key, modificationInfo.lastModifiedBy when using one of the operators contains, starts-with and ends-with is case insensitive. When using the operators =and !=, filtering is case sensitive. The following fields are legal filtering parameters - any other field names will result in a HTTP 400 response: key, supported operators: =, !=, contains, starts-with, ends-with: modificationInfo.lastModifiedTime, supported operators: =, !=, <, <=, >, >= modificationInfo.lastModifiedBy, supported operators: =, !=, contains, starts-with, ends-with validUntilTime, supported operators: =, !=, <, <=, >, >= The following constraints apply: Field names are case-sensitive. Conditions can be connected via operators and and or. A single condition can be negated by not. Strings must be enclosed in single quotes. e.g. key contains 'my-string' Single quotes within a string must be escaped with a backslash: e.g. key starts-with 'it\'s a string' Maximum nesting depth (via brackets) is 2. Maximum length is 256 characters. Examples: key starts-with 'game-' modificationInfo.lastModifiedTime >= '2022-07-01T00:10:05.000Z' and not (key contains 'new') |

Returns

The list of user app states

import { stateClient } from "@dynatrace-sdk/client-state";

const data = await stateClient.getUserAppStates();

setAppState

Updates app state

Required scope: state:app-states:write

Updates the cross-user app state for the given key. Be aware that other users will be able to read the value. Use the user-scoped user-app-state to only store values for the authenticated user.

Certain limits apply when updating app states.

Parameters

| Name | Type | Description | | --- | --- | --- | |config.body*required|AppState| | |config.key*required|string|Specify the key of the state |

import { stateClient } from "@dynatrace-sdk/client-state";

const data = await stateClient.setAppState({
  key: "some-key",
  body: { value: "some-state", validUntilTime: "now+2d" },
});

setUserAppState

Updates user app state

Required scope: state:user-app-states:write

Updates the user specific app state for the given key and calling user.

Certain limits apply when updating user app states.

Parameters

| Name | Type | Description | | --- | --- | --- | |config.body*required|UserAppState| | |config.key*required|string|Specify the key of the state |

import { stateClient } from "@dynatrace-sdk/client-state";

const data = await stateClient.setUserAppState({
  key: "some-key",
  body: { value: "some-state", validUntilTime: "now+2d" },
});

Types

AppState

| Name | Type | Description | | --- | --- | --- | |modificationInfo|ModificationInfo| | |validUntilTime|null | string|Specify the date until the state is persisted. Allowed are values from now+1m to now+90d! Returned validUntilTimes are always a string formatted in ISO 8601 | |value*required|string| |

AppStates

extends Array<ListAppState>

| Name | Type | Description | | --- | --- | --- | |[unscopables]*required|Object|Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. | |length*required|number|Gets or sets the length of the array. This is a number one higher than the highest index in the array. |

Error

| Name | Type | | --- | --- | |code*required|number| |details|ErrorDetails| |message*required|string|

ErrorDetails

| Name | Type | | --- | --- | |errorCode|ErrorDetailsErrorCode|

ErrorResponse

| Name | Type | | --- | --- | |error*required|Error|

ListAppState

| Name | Type | Description | | --- | --- | --- | |key*required|string| | |modificationInfo|ModificationInfo| | |validUntilTime|null | string|Specify the date until the state is persisted. Allowed are values from now+1m to now+90d! Returned validUntilTimes are always a string formatted in ISO 8601 | |value|string| |

ListUserAppState

| Name | Type | Description | | --- | --- | --- | |key*required|string| | |modificationInfo|ModificationInfo| | |validUntilTime|null | string|Specify the date until the state is persisted. Allowed are values from now+1m to now+90d! Returned validUntilTimes are always a string formatted in ISO 8601 | |value|string| |

ModificationInfo

| Name | Type | | --- | --- | |lastModifiedBy*required|string| |lastModifiedTime*required|Date|

PersistenceState

| Name | Type | Description | | --- | --- | --- | |modificationInfo|ModificationInfo| | |validUntilTime|null | string|Specify the date until the state is persisted. Allowed are values from now+1m to now+90d! Returned validUntilTimes are always a string formatted in ISO 8601 | |value|string| |

UserAppState

| Name | Type | Description | | --- | --- | --- | |modificationInfo|ModificationInfo| | |validUntilTime|null | string|Specify the date until the state is persisted. Allowed are values from now+1m to now+90d! Returned validUntilTimes are always a string formatted in ISO 8601 | |value*required|string| |

UserAppStates

extends Array<ListUserAppState>

| Name | Type | Description | | --- | --- | --- | |[unscopables]*required|Object|Is an object whose properties have the value 'true' when they will be absent when used in a 'with' statement. | |length*required|number|Gets or sets the length of the array. This is a number one higher than the highest index in the array. |

Enums

ErrorDetailsErrorCode

Error code indicating the reason why the request failed

  • AppStateOverallSizeLimitExceeded - The overall size limit for the combined size of app states of this app was exceeded
  • UserAppStateSizeLimitExceeded - The user app state content exceeded the size limit for a single user app state
  • UserAppStateCountLimitExceeded - The maximum number of user app states for this user and app was exceeded

Enum keys

AppStateOverallSizeLimitExceeded | UserAppStateCountLimitExceeded | UserAppStateSizeLimitExceeded