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

@forge/storage

Package Overview
Dependencies
Maintainers
8
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@forge/storage - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2-next.0

6

CHANGELOG.md
# @forge/storage
## 1.0.2-next.0
### Patch Changes
- c7c6de2: Support larger list queries for GDPR purposes
## 1.0.1

@@ -4,0 +10,0 @@

48

out/__test__/global-storage.test.js

@@ -5,2 +5,3 @@ "use strict";

const global_storage_1 = require("../global-storage");
const queries_1 = require("../queries");
const contextAri = 'app-ari';

@@ -29,3 +30,3 @@ const getStorage = (apiClientMock) => new global_storage_1.GlobalStorage(() => contextAri, apiClientMock);

describe('GlobalStorage', () => {
function verifyApiClientCalledWith(apiClientMock, variables) {
function verifyApiClientCalledWith(apiClientMock, variables, query) {
expect(apiClientMock).toHaveBeenCalledWith('/forge/entities/graphql', expect.objectContaining({

@@ -39,5 +40,4 @@ method: 'POST',

const [, { body }] = apiClientMock.mock.calls[0];
expect(JSON.parse(body)).toEqual(expect.objectContaining({
variables
}));
const expectedBody = query ? { query, variables } : { variables };
expect(JSON.parse(body)).toEqual(expect.objectContaining(expectedBody));
}

@@ -282,3 +282,40 @@ beforeEach(() => {

limit
}, queries_1.listQuery(contextAri, {}).query);
expect(response).toEqual(expect.objectContaining({
results: [
{ key: 'key1', value: 'testValue' },
{ key: 'key2', value: 'testValue' }
],
nextCursor: 'cursor2'
}));
});
it('should query the appStoredEntitiesForCleanup endpoint given process.env.IS_CLEANUP_FUNCTION is set to true', async () => {
process.env.IS_CLEANUP_FUNCTION = 'true';
const apiClientMock = getApiClientMock({
data: {
appStoredEntities: {
edges: [
{ node: { key: 'key1', value: 'testValue' }, cursor: 'cursor1' },
{ node: { key: 'key2', value: 'testValue' }, cursor: 'cursor2' }
]
}
}
});
const globalStorage = getStorage(apiClientMock);
const where = [
{
field: 'key',
condition: 'STARTS_WITH',
value: 'test'
}
];
const cursor = 'cursor';
const limit = 10;
const response = await globalStorage.list({ where, cursor, limit });
verifyApiClientCalledWith(apiClientMock, {
contextAri,
where,
cursor,
limit
}, queries_1.listQueryForCleanup(contextAri, {}).query);
expect(response).toEqual(expect.objectContaining({

@@ -291,2 +328,3 @@ results: [

}));
process.env.IS_CLEANUP_FUNCTION = '';
});

@@ -308,3 +346,3 @@ it('should use default values', async () => {

limit: null
});
}, queries_1.listQuery(contextAri, {}).query);
});

@@ -311,0 +349,0 @@ it('should handle an empty result set', async () => {

4

out/global-storage.js

@@ -42,3 +42,5 @@ "use strict";

async list(options) {
const requestBody = queries_1.listQuery(this.doGetAppContextAri(), options);
const requestBody = process.env.IS_CLEANUP_FUNCTION === 'true'
? queries_1.listQueryForCleanup(this.doGetAppContextAri(), options)
: queries_1.listQuery(this.doGetAppContextAri(), options);
const { appStoredEntities: { edges } } = await this.query(requestBody);

@@ -45,0 +47,0 @@ const nextCursor = edges.length > 0 ? edges[edges.length - 1].cursor : undefined;

@@ -27,2 +27,11 @@ export declare const getQuery: (contextAri: string, key: string) => {

};
export declare const listQueryForCleanup: (contextAri: string, options: ListOptions) => {
query: string;
variables: {
contextAri: string;
where: WhereClause[] | null;
cursor: string | null;
limit: number | null;
};
};
export declare const setQuery: (contextAri: string, key: string, value: any) => {

@@ -29,0 +38,0 @@ query: string;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deleteQuery = exports.setQuery = exports.listQuery = exports.getQuery = void 0;
exports.deleteQuery = exports.setQuery = exports.listQueryForCleanup = exports.listQuery = exports.getQuery = void 0;
exports.getQuery = (contextAri, key) => ({

@@ -43,2 +43,27 @@ query: `

};
exports.listQueryForCleanup = (contextAri, options) => {
var _a, _b, _c;
return ({
query: `
query List($contextAri: ID!, $where: [AppStoredEntityFilter!], $cursor: String, $limit: Int) {
appStoredEntitiesForCleanup(contextAri: $contextAri, where: $where, after: $cursor, first: $limit) {
edges {
node {
value
key
}
cursor
}
}
}
`,
variables: {
contextAri,
where: (_a = options.where) !== null && _a !== void 0 ? _a : null,
cursor: (_b = options.cursor) !== null && _b !== void 0 ? _b : null,
limit: (_c = options.limit) !== null && _c !== void 0 ? _c : null
}
});
};
exports.setQuery = (contextAri, key, value) => ({

@@ -45,0 +70,0 @@ query: `

{
"name": "@forge/storage",
"version": "1.0.1",
"version": "1.0.2-next.0",
"description": "Forge Storage methods",

@@ -5,0 +5,0 @@ "author": "Atlassian",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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