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

@forge/storage

Package Overview
Dependencies
Maintainers
2
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 0.0.0-experimental-bacec77 to 0.0.0-experimental-c155926

40

out/__test__/global-storage.test.js

@@ -28,2 +28,25 @@ "use strict";

};
const inputSchemas = [
{
name: 'cars',
attributes: {
model: { type: 'string' },
make: { type: 'string' },
rating: { type: 'float' },
year: { type: 'integer' }
},
indexes: [
{
name: 'by-year',
partition: ['year'],
range: 'model'
},
{
name: 'by-make',
partition: ['make'],
range: 'model'
}
]
}
];
const schemas = [

@@ -35,3 +58,4 @@ {

make: { type: 'string' },
year: { type: 'float' }
rating: { type: 'float' },
year: { type: 'integer' }
},

@@ -680,3 +704,3 @@ indexes: [

customSchema: {
createCustomSchema: {
createCustomSchemas: {
success: true

@@ -688,3 +712,3 @@ }

const globalStorage = getStorage(apiClientMock);
await globalStorage.upsertCustomEntities(schemas);
await globalStorage.upsertCustomEntities(inputSchemas);
verifyApiClientCalledWith(apiClientMock, {

@@ -700,3 +724,3 @@ input: {

customSchema: {
createCustomSchema: {
createCustomSchemas: {
success: false,

@@ -709,3 +733,3 @@ errors: [INVALID_CURSOR_ERROR]

const globalStorage = getStorage(apiClientMock);
const response = globalStorage.upsertCustomEntities(schemas);
const response = globalStorage.upsertCustomEntities(inputSchemas);
expect(apiClientMock).toHaveBeenCalled();

@@ -717,3 +741,3 @@ await expect(response).rejects.toThrow(errors_1.APIError.forErrorCode('INVALID_CURSOR', 'error message'));

const globalStorage = getStorage(apiClientMock);
const response = globalStorage.upsertCustomEntities(schemas);
const response = globalStorage.upsertCustomEntities(inputSchemas);
expect(apiClientMock).toHaveBeenCalled();

@@ -726,3 +750,3 @@ await expect(response).rejects.toThrow(errors_1.APIError.forStatus(400));

customSchema: {
createCustomSchema: {
createCustomSchemas: {
success: false

@@ -734,3 +758,3 @@ }

const globalStorage = getStorage(apiClientMock);
await expect(globalStorage.upsertCustomEntities(schemas)).rejects.toThrow(errors_1.APIError.forStatus(500));
await expect(globalStorage.upsertCustomEntities(inputSchemas)).rejects.toThrow(errors_1.APIError.forStatus(500));
verifyApiClientCalledWith(apiClientMock, {

@@ -737,0 +761,0 @@ input: {

import { FetchMethod } from './index';
import { CustomEntityListOptions, CustomEntity, ListOptions } from './query-interfaces';
import { CustomEntityListOptions, ListOptions, CustomEntityInput } from './query-interfaces';
import { SharedStorageAdapter } from './storage-adapter';

@@ -28,3 +28,4 @@ interface ListResults {

deleteEntity(entityName: string, entityKey: string): Promise<void>;
upsertCustomEntities(schemas: CustomEntity[]): Promise<void>;
private getParsedIndex;
upsertCustomEntities(schemas: CustomEntityInput[]): Promise<void>;
private getInternal;

@@ -31,0 +32,0 @@ private getEntityInternal;

17

out/global-storage.js

@@ -95,5 +95,18 @@ "use strict";

}
getParsedIndex(indexes) {
return indexes
? {
indexes: indexes.map((index) => {
return Object.assign(Object.assign({ name: index.name }, (index.partition ? { partition: index.partition } : {})), { range: [index.range] });
})
}
: {};
}
async upsertCustomEntities(schemas) {
const requestBody = gql_queries_1.CustomEntityQueries.createSchema(schemas);
await this.mutation(requestBody, 'customSchema', 'createCustomSchema');
const convertedSchemas = schemas.map((schema) => {
const modifiedSchema = Object.assign({ name: schema.name, attributes: schema.attributes }, this.getParsedIndex(schema.indexes));
return modifiedSchema;
});
const requestBody = gql_queries_1.CustomEntityQueries.createSchema(convertedSchemas);
await this.mutation(requestBody, 'customSchema', 'createCustomSchemas');
}

@@ -100,0 +113,0 @@ async getInternal(key, encrypted) {

@@ -227,3 +227,3 @@ "use strict";

customSchema {
createCustomSchema(input: $input) {
createCustomSchemas(input: $input) {
success

@@ -230,0 +230,0 @@ errors {

@@ -16,3 +16,3 @@ import { RequestInit, Response } from 'node-fetch';

entity: (entityName: string) => EntityStorageBuilder;
upsertCustomEntities: (schemas: import("./query-interfaces").CustomEntity[]) => Promise<void>;
upsertCustomEntities: (schemas: import("./query-interfaces").CustomEntityInput[]) => Promise<void>;
};

@@ -23,4 +23,4 @@ export { GlobalStorage } from './global-storage';

export { QueryBuilder, QueryApi, Condition, ListResult, Predicate, Result, EntityStorageApi, WherePredicate, FilterPredicate } from './storage-adapter';
export { Value, CustomEntity } from './query-interfaces';
export { Value, CustomEntityInput } from './query-interfaces';
export { APIError } from './errors';
//# sourceMappingURL=index.d.ts.map

@@ -109,14 +109,27 @@ export declare type Value = string;

}
export declare type CustomEntityInputIndex = {
name: string;
partition?: string[];
range: string;
};
export declare type CustomEntityInput = {
name: string;
attributes: Record<string, {
type: 'string' | 'float' | 'boolean' | 'integer' | 'any';
}>;
indexes?: CustomEntityInputIndex[];
};
export declare type CustomEntityRequestIndex = {
name: string;
partition?: string[];
range: string[];
};
export declare type CustomEntity = {
name: string;
attributes: Record<string, {
type: 'string' | 'float' | 'boolean' | 'any';
type: 'string' | 'float' | 'boolean' | 'integer' | 'any';
}>;
indexes?: {
name: string;
partition: string[];
range: string[];
}[];
indexes?: CustomEntityRequestIndex[];
};
export {};
//# sourceMappingURL=query-interfaces.d.ts.map
import { EntityStorageBuilderType } from './entity-storage';
import { BeginsWithClause, BetweenClause, ExistsClause, DoesNotExistClause, FilterOperator, GreaterThanClause, GreaterThanEqualToClause, StartsWith, NotEqualTo, In, LessThanClause, LessThanEqualToClause, ContainsClause, DoesNotContainClause, IsNotEqualToClause, EqualToClause, SortOrder, CustomEntity, CustomEntityPartitionValue } from './query-interfaces';
import { BeginsWithClause, BetweenClause, ExistsClause, DoesNotExistClause, FilterOperator, GreaterThanClause, GreaterThanEqualToClause, StartsWith, NotEqualTo, In, LessThanClause, LessThanEqualToClause, ContainsClause, DoesNotContainClause, IsNotEqualToClause, EqualToClause, SortOrder, CustomEntityPartitionValue, CustomEntityInput } from './query-interfaces';
export interface StorageAdapter {

@@ -10,3 +10,3 @@ get(key: string): Promise<any>;

deleteSecret(key: string): Promise<void>;
upsertCustomEntities(schemas: CustomEntity[]): Promise<void>;
upsertCustomEntities(schemas: CustomEntityInput[]): Promise<void>;
}

@@ -23,3 +23,3 @@ export interface EntityStorageAdapter {

export interface QueryApi {
query(): QueryBuilder | CustomEntityQueryBuilder;
query(): QueryBuilder;
}

@@ -39,3 +39,3 @@ export declare type Predicate = StartsWith | NotEqualTo | In;

index(indexName: string): CustomEntityQueryBuilder;
partition(parition: CustomEntityPartitionValue[]): CustomEntityQueryBuilder;
partition(partition: CustomEntityPartitionValue[]): CustomEntityQueryBuilder;
where(condition: WherePredicate): CustomEntityQueryBuilder;

@@ -42,0 +42,0 @@ sortOrder(sort: SortOrder): CustomEntityQueryBuilder;

{
"name": "@forge/storage",
"version": "0.0.0-experimental-bacec77",
"version": "0.0.0-experimental-c155926",
"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

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