@forge/cache 1.0.2 → 1.0.3-next.0-experimental-ab129b0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/out/cache.d.ts +4 -1
  2. package/out/cache.d.ts.map +1 -1
  3. package/out/cache.js +11 -0
  4. package/out/kvs/conditions.d.ts +38 -0
  5. package/out/kvs/conditions.d.ts.map +1 -0
  6. package/out/kvs/conditions.js +98 -0
  7. package/out/kvs/entity-query.d.ts +26 -0
  8. package/out/kvs/entity-query.d.ts.map +1 -0
  9. package/out/kvs/entity-query.js +102 -0
  10. package/out/kvs/entity.d.ts +13 -0
  11. package/out/kvs/entity.d.ts.map +1 -0
  12. package/out/kvs/entity.js +35 -0
  13. package/out/kvs/errors.d.ts +21 -0
  14. package/out/kvs/errors.d.ts.map +1 -0
  15. package/out/kvs/errors.js +26 -0
  16. package/out/kvs/index.d.ts +10 -0
  17. package/out/kvs/index.d.ts.map +1 -0
  18. package/out/kvs/index.js +42 -0
  19. package/out/kvs/interfaces/entity-query.d.ts +41 -0
  20. package/out/kvs/interfaces/entity-query.d.ts.map +1 -0
  21. package/out/kvs/interfaces/entity-query.js +2 -0
  22. package/out/kvs/interfaces/kvs-api.d.ts +95 -0
  23. package/out/kvs/interfaces/kvs-api.d.ts.map +1 -0
  24. package/out/kvs/interfaces/kvs-api.js +2 -0
  25. package/out/kvs/interfaces/kvs.d.ts +21 -0
  26. package/out/kvs/interfaces/kvs.d.ts.map +1 -0
  27. package/out/kvs/interfaces/kvs.js +2 -0
  28. package/out/kvs/interfaces/query.d.ts +17 -0
  29. package/out/kvs/interfaces/query.d.ts.map +1 -0
  30. package/out/kvs/interfaces/query.js +2 -0
  31. package/out/kvs/interfaces/transaction.d.ts +29 -0
  32. package/out/kvs/interfaces/transaction.d.ts.map +1 -0
  33. package/out/kvs/interfaces/transaction.js +2 -0
  34. package/out/kvs/interfaces/types.d.ts +64 -0
  35. package/out/kvs/interfaces/types.d.ts.map +1 -0
  36. package/out/kvs/interfaces/types.js +8 -0
  37. package/out/kvs/kvs.d.ts +18 -0
  38. package/out/kvs/kvs.d.ts.map +1 -0
  39. package/out/kvs/kvs.js +40 -0
  40. package/out/kvs/query.d.ts +14 -0
  41. package/out/kvs/query.d.ts.map +1 -0
  42. package/out/kvs/query.js +38 -0
  43. package/out/kvs/storage-api.d.ts +22 -0
  44. package/out/kvs/storage-api.d.ts.map +1 -0
  45. package/out/kvs/storage-api.js +103 -0
  46. package/out/kvs/transaction-api.d.ts +14 -0
  47. package/out/kvs/transaction-api.d.ts.map +1 -0
  48. package/out/kvs/transaction-api.js +66 -0
  49. package/out/kvs/utils/error-handling.d.ts +7 -0
  50. package/out/kvs/utils/error-handling.d.ts.map +1 -0
  51. package/out/kvs/utils/error-handling.js +42 -0
  52. package/out/kvs/utils/transaction-request-builder.d.ts +6 -0
  53. package/out/kvs/utils/transaction-request-builder.d.ts.map +1 -0
  54. package/out/kvs/utils/transaction-request-builder.js +49 -0
  55. package/package.json +2 -2
  56. package/out/__test__/cache.test.d.ts +0 -2
  57. package/out/__test__/cache.test.d.ts.map +0 -1
  58. package/out/__test__/cache.test.js +0 -358
  59. package/out/__test__/tunnel.test.d.ts +0 -2
  60. package/out/__test__/tunnel.test.d.ts.map +0 -1
  61. package/out/__test__/tunnel.test.js +0 -176
package/out/cache.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { RequestInit, Response as nodeFetchResponse } from 'node-fetch';
2
2
  import { TunnelCache } from './tunnel';
3
3
  import { IForgeCache } from './interfaces/cache';
4
- export declare type Response = Pick<nodeFetchResponse, 'text' | 'ok' | 'status'>;
4
+ export declare type Response = nodeFetchResponse;
5
5
  export declare type ScanResult = {
6
6
  cursor: string;
7
7
  keys: string[];
@@ -15,8 +15,11 @@ export declare class ApiError extends Error {
15
15
  export declare function getResponseBody(response: Response): Promise<any>;
16
16
  export declare class Cache implements IForgeCache {
17
17
  private client;
18
+ private kvsImpl;
18
19
  constructor(client: (path: string, options?: RequestInit) => Promise<Response>);
19
20
  private buildRequest;
21
+ setKvs<T>(key: string, value: T): Promise<void>;
22
+ getKvs<T>(key: string): Promise<T | undefined>;
20
23
  set(key: string, value: string, opt?: {
21
24
  ttlSeconds: number;
22
25
  }): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"cache.d.ts","sourceRoot":"","sources":["../src/cache.ts"],"names":[],"mappings":"AACA,OAAkB,EAAE,WAAW,EAAE,QAAQ,IAAI,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEnF,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,oBAAY,QAAQ,GAAG,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,GAAG,QAAQ,CAAC,CAAC;AAEzE,oBAAY,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,EAAE,CAAC;CAChB,CAAC;AAEF,qBAAa,QAAS,SAAQ,KAAK;IAE/B,QAAQ,CAAC,MAAM,EAAE,MAAM;IACvB,QAAQ,CAAC,IAAI,EAAE,MAAM;IAErB,QAAQ,CAAC,IAAI,CAAC;gBAHL,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACN,IAAI,CAAC,KAAK;CAItB;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,CA6BtE;AAED,qBAAa,KAAM,YAAW,WAAW;IAC3B,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC;IAGtF,OAAO,CAAC,YAAY;IAUP,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,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UrD,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAU7C,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;CAMtD;AAQD,wBAAgB,uBAAuB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAiCpG;AAED,wBAAgB,OAAO,CAAC,kBAAkB,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,WAAW,CAQxE"}
package/out/cache.js CHANGED
@@ -5,6 +5,8 @@ const tslib_1 = require("tslib");
5
5
  const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
6
6
  const api_1 = require("@forge/api");
7
7
  const tunnel_1 = require("./tunnel");
8
+ const kvs_1 = require("./kvs/kvs");
9
+ const storage_api_1 = require("./kvs/storage-api");
8
10
  class ApiError extends Error {
9
11
  status;
10
12
  code;
@@ -43,8 +45,11 @@ async function getResponseBody(response) {
43
45
  exports.getResponseBody = getResponseBody;
44
46
  class Cache {
45
47
  client;
48
+ kvsImpl;
46
49
  constructor(client) {
47
50
  this.client = client;
51
+ const storageApi = new storage_api_1.StorageApi(client);
52
+ this.kvsImpl = new kvs_1.KvsImpl(storageApi);
48
53
  }
49
54
  buildRequest(requestBody) {
50
55
  return {
@@ -55,6 +60,12 @@ class Cache {
55
60
  }
56
61
  };
57
62
  }
63
+ async setKvs(key, value) {
64
+ return await this.kvsImpl.set(key, value);
65
+ }
66
+ async getKvs(key) {
67
+ return await this.kvsImpl.get(key);
68
+ }
58
69
  async set(key, value, opt) {
59
70
  const response = await this.client('rms/store/set', this.buildRequest({ key, value, ...opt }));
60
71
  await getResponseBody(response);
@@ -0,0 +1,38 @@
1
+ import { BeginsWithClause, BetweenClause, ContainsClause, EqualToClause, ExistsClause, GreaterThanClause, GreaterThanEqualToClause, LessThanClause, LessThanEqualToClause, NotContainsClause, NotEqualToClause, NotExistsClause, StringOrNumber, StringOrNumberOrBoolean } from './interfaces/types';
2
+ declare function between<T extends StringOrNumber>(firstValue: T, secondValue: T): BetweenClause<T>;
3
+ declare function beginsWith(value: StringOrNumber): BeginsWithClause;
4
+ declare function exists(): ExistsClause;
5
+ declare function notExists(): NotExistsClause;
6
+ declare function greaterThan(value: StringOrNumber): GreaterThanClause;
7
+ declare function greaterThanEqualTo(value: StringOrNumber): GreaterThanEqualToClause;
8
+ declare function lessThan(value: StringOrNumber): LessThanClause;
9
+ declare function lessThanEqualTo(value: StringOrNumber): LessThanEqualToClause;
10
+ declare function contains(value: string): ContainsClause;
11
+ declare function notContains(value: string): NotContainsClause;
12
+ declare function equalTo(value: StringOrNumberOrBoolean): EqualToClause;
13
+ declare function notEqualTo(value: StringOrNumberOrBoolean): NotEqualToClause;
14
+ export declare const WhereConditions: {
15
+ beginsWith: typeof beginsWith;
16
+ between: typeof between;
17
+ equalTo: typeof equalTo;
18
+ greaterThan: typeof greaterThan;
19
+ greaterThanEqualTo: typeof greaterThanEqualTo;
20
+ lessThan: typeof lessThan;
21
+ lessThanEqualTo: typeof lessThanEqualTo;
22
+ };
23
+ export declare const FilterConditions: {
24
+ beginsWith: typeof beginsWith;
25
+ between: typeof between;
26
+ contains: typeof contains;
27
+ notContains: typeof notContains;
28
+ equalTo: typeof equalTo;
29
+ notEqualTo: typeof notEqualTo;
30
+ exists: typeof exists;
31
+ notExists: typeof notExists;
32
+ greaterThan: typeof greaterThan;
33
+ greaterThanEqualTo: typeof greaterThanEqualTo;
34
+ lessThan: typeof lessThan;
35
+ lessThanEqualTo: typeof lessThanEqualTo;
36
+ };
37
+ export {};
38
+ //# sourceMappingURL=conditions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conditions.d.ts","sourceRoot":"","sources":["../../src/kvs/conditions.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,cAAc,EACd,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,uBAAuB,EACxB,MAAM,oBAAoB,CAAC;AAE5B,iBAAS,OAAO,CAAC,CAAC,SAAS,cAAc,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAK1F;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,gBAAgB,CAK3D;AAED,iBAAS,MAAM,IAAI,YAAY,CAK9B;AAED,iBAAS,SAAS,IAAI,eAAe,CAKpC;AAED,iBAAS,WAAW,CAAC,KAAK,EAAE,cAAc,GAAG,iBAAiB,CAK7D;AAED,iBAAS,kBAAkB,CAAC,KAAK,EAAE,cAAc,GAAG,wBAAwB,CAK3E;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CAKvD;AAED,iBAAS,eAAe,CAAC,KAAK,EAAE,cAAc,GAAG,qBAAqB,CAKrE;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAK/C;AAED,iBAAS,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAKrD;AAED,iBAAS,OAAO,CAAC,KAAK,EAAE,uBAAuB,GAAG,aAAa,CAK9D;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,uBAAuB,GAAG,gBAAgB,CAKpE;AAED,eAAO,MAAM,eAAe;;;;;;;;CAQ3B,CAAC;AAEF,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;CAa5B,CAAC"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilterConditions = exports.WhereConditions = void 0;
4
+ function between(firstValue, secondValue) {
5
+ return {
6
+ condition: 'BETWEEN',
7
+ values: [firstValue, secondValue]
8
+ };
9
+ }
10
+ function beginsWith(value) {
11
+ return {
12
+ condition: 'BEGINS_WITH',
13
+ values: [value]
14
+ };
15
+ }
16
+ function exists() {
17
+ return {
18
+ condition: 'EXISTS',
19
+ values: [true]
20
+ };
21
+ }
22
+ function notExists() {
23
+ return {
24
+ condition: 'NOT_EXISTS',
25
+ values: [true]
26
+ };
27
+ }
28
+ function greaterThan(value) {
29
+ return {
30
+ condition: 'GREATER_THAN',
31
+ values: [value]
32
+ };
33
+ }
34
+ function greaterThanEqualTo(value) {
35
+ return {
36
+ condition: 'GREATER_THAN_EQUAL_TO',
37
+ values: [value]
38
+ };
39
+ }
40
+ function lessThan(value) {
41
+ return {
42
+ condition: 'LESS_THAN',
43
+ values: [value]
44
+ };
45
+ }
46
+ function lessThanEqualTo(value) {
47
+ return {
48
+ condition: 'LESS_THAN_EQUAL_TO',
49
+ values: [value]
50
+ };
51
+ }
52
+ function contains(value) {
53
+ return {
54
+ condition: 'CONTAINS',
55
+ values: [value]
56
+ };
57
+ }
58
+ function notContains(value) {
59
+ return {
60
+ condition: 'NOT_CONTAINS',
61
+ values: [value]
62
+ };
63
+ }
64
+ function equalTo(value) {
65
+ return {
66
+ condition: 'EQUAL_TO',
67
+ values: [value]
68
+ };
69
+ }
70
+ function notEqualTo(value) {
71
+ return {
72
+ condition: 'NOT_EQUAL_TO',
73
+ values: [value]
74
+ };
75
+ }
76
+ exports.WhereConditions = {
77
+ beginsWith,
78
+ between,
79
+ equalTo,
80
+ greaterThan,
81
+ greaterThanEqualTo,
82
+ lessThan,
83
+ lessThanEqualTo
84
+ };
85
+ exports.FilterConditions = {
86
+ beginsWith,
87
+ between,
88
+ contains,
89
+ notContains,
90
+ equalTo,
91
+ notEqualTo,
92
+ exists,
93
+ notExists,
94
+ greaterThan,
95
+ greaterThanEqualTo,
96
+ lessThan,
97
+ lessThanEqualTo
98
+ };
@@ -0,0 +1,26 @@
1
+ import { EntityFilterClauses, AndFilter, EntityQueryBuilder, IndexQueryBuilder, Filter, FilterItem, IndexOptions, OrFilter } from './interfaces/entity-query';
2
+ import { StorageApi } from './storage-api';
3
+ export declare class KvsIndexQueryBuilder<T> implements IndexQueryBuilder<T> {
4
+ private readonly entityName;
5
+ private readonly storageApi;
6
+ constructor(entityName: string, storageApi: StorageApi);
7
+ index(name: string, indexOptions?: IndexOptions<T>): EntityQueryBuilder<T>;
8
+ }
9
+ export declare abstract class BaseFilter<T> {
10
+ protected readonly items: Array<FilterItem<T>>;
11
+ constructor(items?: Array<FilterItem<T>>);
12
+ filters(): Array<FilterItem<T>>;
13
+ operator(): "or" | "and";
14
+ }
15
+ export declare class FilterBuilder<T> extends BaseFilter<T> implements Filter<T> {
16
+ and(field: keyof T, condition: EntityFilterClauses): AndFilterBuilder<T>;
17
+ or(field: keyof T, condition: EntityFilterClauses): OrFilterBuilder<T>;
18
+ }
19
+ declare class AndFilterBuilder<T> extends BaseFilter<T> implements AndFilter<T> {
20
+ and(field: keyof T, condition: EntityFilterClauses): this;
21
+ }
22
+ declare class OrFilterBuilder<T> extends BaseFilter<T> implements OrFilter<T> {
23
+ or(field: keyof T, condition: EntityFilterClauses): this;
24
+ }
25
+ export {};
26
+ //# sourceMappingURL=entity-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-query.d.ts","sourceRoot":"","sources":["../../src/kvs/entity-query.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EAGnB,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,EACN,UAAU,EACV,YAAY,EACZ,QAAQ,EACT,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,qBAAa,oBAAoB,CAAC,CAAC,CAAE,YAAW,iBAAiB,CAAC,CAAC,CAAC;IAEhE,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,UAAU;IAGzC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC;CAQ3E;AAwDD,8BAAsB,UAAU,CAAC,CAAC;IACpB,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBAA3B,KAAK,GAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAM;IAExD,OAAO,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAI/B,QAAQ;CAGhB;AAED,qBAAa,aAAa,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAE,YAAW,MAAM,CAAC,CAAC,CAAC;IACtE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,mBAAmB,GAAG,gBAAgB,CAAC,CAAC,CAAC;IAIxE,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,mBAAmB,GAAG,eAAe,CAAC,CAAC,CAAC;CAGvE;AAED,cAAM,gBAAgB,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAE,YAAW,SAAS,CAAC,CAAC,CAAC;IACrE,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,mBAAmB,GAAG,IAAI;CAI1D;AAED,cAAM,eAAe,CAAC,CAAC,CAAE,SAAQ,UAAU,CAAC,CAAC,CAAE,YAAW,QAAQ,CAAC,CAAC,CAAC;IACnE,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,mBAAmB,GAAG,IAAI;CAIzD"}
@@ -0,0 +1,102 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilterBuilder = exports.BaseFilter = exports.KvsIndexQueryBuilder = void 0;
4
+ class KvsIndexQueryBuilder {
5
+ entityName;
6
+ storageApi;
7
+ constructor(entityName, storageApi) {
8
+ this.entityName = entityName;
9
+ this.storageApi = storageApi;
10
+ }
11
+ index(name, indexOptions) {
12
+ return new KvsEntityQueryBuilder(this.storageApi, {
13
+ entityName: this.entityName,
14
+ indexName: name,
15
+ partition: indexOptions?.partition,
16
+ filters: []
17
+ });
18
+ }
19
+ }
20
+ exports.KvsIndexQueryBuilder = KvsIndexQueryBuilder;
21
+ class KvsEntityQueryBuilder {
22
+ storageApi;
23
+ queryOptions;
24
+ constructor(storageApi, queryOptions) {
25
+ this.storageApi = storageApi;
26
+ this.queryOptions = queryOptions;
27
+ }
28
+ where(condition) {
29
+ this.queryOptions.range = condition;
30
+ return this;
31
+ }
32
+ filters(filter) {
33
+ this.queryOptions.filters = filter.filters();
34
+ this.queryOptions.filterOperator = filter.operator();
35
+ return this;
36
+ }
37
+ sort(sort) {
38
+ this.queryOptions.sort = sort;
39
+ return this;
40
+ }
41
+ cursor(cursor) {
42
+ this.queryOptions.cursor = cursor;
43
+ return this;
44
+ }
45
+ limit(limit) {
46
+ this.queryOptions.limit = limit;
47
+ return this;
48
+ }
49
+ async getOne() {
50
+ const { results } = await this.limit(1).getMany();
51
+ if (results && results.length > 0) {
52
+ return results[0];
53
+ }
54
+ return undefined;
55
+ }
56
+ async getMany() {
57
+ const { filters, filterOperator, ...rest } = this.queryOptions;
58
+ if (filters && filterOperator && filters.length > 0) {
59
+ return this.storageApi.queryEntity({
60
+ ...rest,
61
+ filters: {
62
+ [filterOperator]: filters
63
+ }
64
+ });
65
+ }
66
+ return this.storageApi.queryEntity(rest);
67
+ }
68
+ }
69
+ class BaseFilter {
70
+ items;
71
+ constructor(items = []) {
72
+ this.items = items;
73
+ }
74
+ filters() {
75
+ return this.items;
76
+ }
77
+ operator() {
78
+ return this instanceof AndFilterBuilder ? 'and' : 'or';
79
+ }
80
+ }
81
+ exports.BaseFilter = BaseFilter;
82
+ class FilterBuilder extends BaseFilter {
83
+ and(field, condition) {
84
+ return new AndFilterBuilder().and(field, condition);
85
+ }
86
+ or(field, condition) {
87
+ return new OrFilterBuilder().or(field, condition);
88
+ }
89
+ }
90
+ exports.FilterBuilder = FilterBuilder;
91
+ class AndFilterBuilder extends BaseFilter {
92
+ and(field, condition) {
93
+ this.items.push({ property: field, ...condition });
94
+ return this;
95
+ }
96
+ }
97
+ class OrFilterBuilder extends BaseFilter {
98
+ or(field, condition) {
99
+ this.items.push({ property: field, ...condition });
100
+ return this;
101
+ }
102
+ }
@@ -0,0 +1,13 @@
1
+ import { IndexQueryBuilder } from './interfaces/entity-query';
2
+ import { KvsEntity } from './interfaces/kvs';
3
+ import { StorageApi } from './storage-api';
4
+ export declare class EntityImpl<T> implements KvsEntity<T> {
5
+ private readonly entityName;
6
+ private readonly storageApi;
7
+ constructor(entityName: string, storageApi: StorageApi);
8
+ get(key: string): Promise<T | undefined>;
9
+ set(key: string, value: T): Promise<void>;
10
+ delete(key: string): Promise<void>;
11
+ query(): IndexQueryBuilder<T>;
12
+ }
13
+ //# sourceMappingURL=entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../src/kvs/entity.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3C,qBAAa,UAAU,CAAC,CAAC,CAAE,YAAW,SAAS,CAAC,CAAC,CAAC;IAE9C,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,UAAU;gBADV,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,UAAU;IAGzC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;IAOxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzC,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAOlC,KAAK,IAAI,iBAAiB,CAAC,CAAC,CAAC;CAG9B"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EntityImpl = void 0;
4
+ const entity_query_1 = require("./entity-query");
5
+ class EntityImpl {
6
+ entityName;
7
+ storageApi;
8
+ constructor(entityName, storageApi) {
9
+ this.entityName = entityName;
10
+ this.storageApi = storageApi;
11
+ }
12
+ get(key) {
13
+ return this.storageApi.getEntity({
14
+ entityName: this.entityName,
15
+ key
16
+ });
17
+ }
18
+ set(key, value) {
19
+ return this.storageApi.setEntity({
20
+ entityName: this.entityName,
21
+ key,
22
+ value
23
+ });
24
+ }
25
+ delete(key) {
26
+ return this.storageApi.deleteEntity({
27
+ entityName: this.entityName,
28
+ key
29
+ });
30
+ }
31
+ query() {
32
+ return new entity_query_1.KvsIndexQueryBuilder(this.entityName, this.storageApi);
33
+ }
34
+ }
35
+ exports.EntityImpl = EntityImpl;
@@ -0,0 +1,21 @@
1
+ export interface ForgeError {
2
+ code: string;
3
+ message: string;
4
+ context?: Record<string, unknown>;
5
+ }
6
+ export interface APIErrorResponseDetails {
7
+ status: number;
8
+ statusText: string;
9
+ traceId?: string | null;
10
+ }
11
+ export declare class ForgeKvsError extends Error {
12
+ constructor(message: string);
13
+ }
14
+ export declare class ForgeKvsAPIError extends ForgeKvsError {
15
+ responseDetails: APIErrorResponseDetails;
16
+ code: string;
17
+ message: string;
18
+ context: Record<string, unknown>;
19
+ constructor(responseDetails: APIErrorResponseDetails, forgeError: ForgeError);
20
+ }
21
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/kvs/errors.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACzB;AAED,qBAAa,aAAc,SAAQ,KAAK;gBAC1B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,gBAAiB,SAAQ,aAAa;IACjD,eAAe,EAAE,uBAAuB,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAErB,eAAe,EAAE,uBAAuB,EAAE,UAAU,EAAE,UAAU;CAU7E"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ForgeKvsAPIError = exports.ForgeKvsError = void 0;
4
+ class ForgeKvsError extends Error {
5
+ constructor(message) {
6
+ super(message);
7
+ this.name = 'ForgeKvsError';
8
+ }
9
+ }
10
+ exports.ForgeKvsError = ForgeKvsError;
11
+ class ForgeKvsAPIError extends ForgeKvsError {
12
+ responseDetails;
13
+ code;
14
+ message;
15
+ context;
16
+ constructor(responseDetails, forgeError) {
17
+ super(forgeError.message);
18
+ const { status, statusText, traceId } = responseDetails;
19
+ this.responseDetails = { status, statusText, traceId };
20
+ const { code, message, context, ...bodyData } = forgeError;
21
+ this.code = code;
22
+ this.message = message;
23
+ this.context = { ...context, ...bodyData };
24
+ }
25
+ }
26
+ exports.ForgeKvsAPIError = ForgeKvsAPIError;
@@ -0,0 +1,10 @@
1
+ import { KvsImpl } from './kvs';
2
+ declare const kvs: KvsImpl;
3
+ export { FilterConditions, WhereConditions } from './conditions';
4
+ export { FilterBuilder as Filter } from './entity-query';
5
+ export * from './errors';
6
+ export { AndFilter, OrFilter } from './interfaces/entity-query';
7
+ export * from './interfaces/types';
8
+ export { kvs };
9
+ export default kvs;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/kvs/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAqChC,QAAA,MAAM,GAAG,SAA0B,CAAC;AAEpC,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACjE,OAAO,EAAE,aAAa,IAAI,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACzD,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAChE,cAAc,oBAAoB,CAAC;AACnC,OAAO,EAAE,GAAG,EAAE,CAAC;AACf,eAAe,GAAG,CAAC"}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.kvs = exports.Filter = exports.WhereConditions = exports.FilterConditions = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const kvs_1 = require("./kvs");
6
+ const storage_api_1 = require("./storage-api");
7
+ function getFetchClient() {
8
+ const runtime = global.__forge_runtime__;
9
+ if (runtime?.kvs?.url && runtime?.kvs?.host) {
10
+ const { proxy, kvs, tracing } = runtime;
11
+ return async function (path, options) {
12
+ return await global.__forge_fetch__({ type: 'kvs' }, path, {
13
+ ...options,
14
+ headers: {
15
+ ...options?.headers,
16
+ Authorization: `Bearer ${proxy.token}`,
17
+ Host: kvs?.host,
18
+ 'x-b3-traceid': tracing.traceId,
19
+ 'x-b3-spanid': tracing.spanId
20
+ }
21
+ });
22
+ };
23
+ }
24
+ return async function (path, options) {
25
+ return await global.__forge_fetch__({
26
+ type: 'kvs',
27
+ provider: 'app',
28
+ remote: 'kvs'
29
+ }, path, options);
30
+ };
31
+ }
32
+ const storageApi = new storage_api_1.StorageApi(getFetchClient());
33
+ const kvs = new kvs_1.KvsImpl(storageApi);
34
+ exports.kvs = kvs;
35
+ var conditions_1 = require("./conditions");
36
+ Object.defineProperty(exports, "FilterConditions", { enumerable: true, get: function () { return conditions_1.FilterConditions; } });
37
+ Object.defineProperty(exports, "WhereConditions", { enumerable: true, get: function () { return conditions_1.WhereConditions; } });
38
+ var entity_query_1 = require("./entity-query");
39
+ Object.defineProperty(exports, "Filter", { enumerable: true, get: function () { return entity_query_1.FilterBuilder; } });
40
+ tslib_1.__exportStar(require("./errors"), exports);
41
+ tslib_1.__exportStar(require("./interfaces/types"), exports);
42
+ exports.default = kvs;
@@ -0,0 +1,41 @@
1
+ import { BeginsWithClause, BetweenClause, ContainsClause, EqualToClause, ExistsClause, FilterOperator, GreaterThanClause, GreaterThanEqualToClause, LessThanClause, LessThanEqualToClause, ListResult, NotContainsClause, NotEqualToClause, NotExistsClause, Result, Sort, StringOrNumber } from './types';
2
+ export declare type IndexOptions<T> = Pick<EntityQueryOptions<T>, 'partition'>;
3
+ export interface IndexQueryBuilder<T> {
4
+ index(name: string, indexOptions?: IndexOptions<T>): EntityQueryBuilder<T>;
5
+ }
6
+ export interface EntityQueryBuilder<T> {
7
+ where(condition: EntityWhereClauses): this;
8
+ filters(filters: AndFilter<T> | OrFilter<T>): this;
9
+ sort(sort: Sort): this;
10
+ cursor(cursor: string): this;
11
+ limit(limit: number): this;
12
+ getOne(): Promise<Result<T> | undefined>;
13
+ getMany(): Promise<ListResult<T>>;
14
+ }
15
+ export declare type FilterItem<T> = EntityFilterClauses & {
16
+ property: keyof T;
17
+ };
18
+ export interface Filter<T> {
19
+ and(field: keyof T, condition: EntityFilterClauses): AndFilter<T>;
20
+ or(field: keyof T, condition: EntityFilterClauses): OrFilter<T>;
21
+ }
22
+ export interface AndFilter<T> {
23
+ and(field: keyof T, condition: EntityFilterClauses): this;
24
+ }
25
+ export interface OrFilter<T> {
26
+ or(field: keyof T, condition: EntityFilterClauses): this;
27
+ }
28
+ export declare type EntityFilterClauses = BetweenClause<StringOrNumber> | BeginsWithClause | ExistsClause | NotExistsClause | GreaterThanClause | GreaterThanEqualToClause | LessThanClause | LessThanEqualToClause | ContainsClause | NotContainsClause | EqualToClause | NotEqualToClause;
29
+ export declare type EntityWhereClauses = BetweenClause<StringOrNumber> | BeginsWithClause | EqualToClause | GreaterThanClause | GreaterThanEqualToClause | LessThanClause | LessThanEqualToClause;
30
+ export interface EntityQueryOptions<T> {
31
+ sort?: Sort;
32
+ entityName: string;
33
+ indexName: string;
34
+ partition?: Array<unknown>;
35
+ range?: EntityWhereClauses;
36
+ filters?: Array<FilterItem<T>>;
37
+ filterOperator?: FilterOperator;
38
+ cursor?: string;
39
+ limit?: number;
40
+ }
41
+ //# sourceMappingURL=entity-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-query.d.ts","sourceRoot":"","sources":["../../../src/kvs/interfaces/entity-query.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,wBAAwB,EACxB,cAAc,EACd,qBAAqB,EACrB,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,IAAI,EACJ,cAAc,EACf,MAAM,SAAS,CAAC;AAEjB,oBAAY,YAAY,CAAC,CAAC,IAAI,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;AAEvE,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC,CAAC;CAC5E;AAED,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,KAAK,CAAC,SAAS,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC3C,OAAO,CAAC,OAAO,EAAE,SAAS,CA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C,cAAc,CAAC,GAC7B,gBAAgB,GAChB,aAAa,GACb,iBAAiB,GACjB,wBAAwB,GACxB,cAAc,GACd,qBAAqB,CAAC;AAE1B,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3B,KAAK,CAAC,EAAE,kBAAkB,CAAC;IAC3B,OAAO,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IAC/B,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,95 @@
1
+ declare type KeySchema = {
2
+ key: string;
3
+ };
4
+ declare type KeyValueSchema<T> = KeySchema & {
5
+ value: T;
6
+ };
7
+ export declare type GetRequest = KeySchema;
8
+ export declare type GetResponse<T> = KeyValueSchema<T>;
9
+ export declare type SetRequest<T> = KeyValueSchema<T>;
10
+ export declare type SetResponse = void;
11
+ export declare type DeleteRequest = KeySchema;
12
+ export declare type DeleteResponse = void;
13
+ declare type QueryWhere = {
14
+ condition: 'BEGINS_WITH';
15
+ property: 'key';
16
+ values: Array<unknown>;
17
+ };
18
+ export declare type QueryRequest = {
19
+ limit?: number;
20
+ after?: string;
21
+ where?: Array<QueryWhere>;
22
+ };
23
+ export declare type QueryResponse<T> = {
24
+ data: Array<KeyValueSchema<T>>;
25
+ cursor?: string;
26
+ };
27
+ export declare type SecretGetRequest = KeySchema;
28
+ export declare type SecretGetResponse<T> = KeyValueSchema<T>;
29
+ export declare type SecretSetRequest<T> = KeyValueSchema<T>;
30
+ export declare type SecretSetResponse = void;
31
+ export declare type SecretDeleteRequest = KeySchema;
32
+ export declare type SecretDeleteResponse = void;
33
+ declare type EntityKeySchema = {
34
+ entityName: string;
35
+ key: string;
36
+ };
37
+ declare type EntityKeyValueSchema<T> = EntityKeySchema & {
38
+ value: T;
39
+ };
40
+ export declare type EntityGetRequest = EntityKeySchema;
41
+ export declare type EntityGetResponse<T> = EntityKeyValueSchema<T>;
42
+ export declare type EntitySetRequest<T> = EntityKeyValueSchema<T>;
43
+ export declare type EntitySetResponse = void;
44
+ export declare type EntityDeleteRequest = EntityKeySchema;
45
+ export declare type EntityDeleteResponse = void;
46
+ export declare type EntityQueryFilter = {
47
+ condition: 'BEGINS_WITH' | 'BETWEEN' | 'CONTAINS' | 'EQUAL_TO' | 'EXISTS' | 'GREATER_THAN' | 'GREATER_THAN_EQUAL_TO' | 'LESS_THAN' | 'LESS_THAN_EQUAL_TO' | 'NOT_CONTAINS' | 'NOT_EQUAL_TO' | 'NOT_EXISTS';
48
+ property: string;
49
+ values: Array<unknown>;
50
+ };
51
+ export declare type EntityQueryFilters = {
52
+ or?: Array<EntityQueryFilter>;
53
+ and?: Array<EntityQueryFilter>;
54
+ };
55
+ export declare type EntityQueryRequest = {
56
+ limit?: number;
57
+ cursor?: string;
58
+ range?: {
59
+ condition: 'BEGINS_WITH' | 'BETWEEN' | 'EQUAL_TO' | 'GREATER_THAN' | 'GREATER_THAN_EQUAL_TO' | 'LESS_THAN' | 'LESS_THAN_EQUAL_TO';
60
+ values: Array<unknown>;
61
+ };
62
+ filters?: EntityQueryFilters;
63
+ sort?: 'ASC' | 'DESC';
64
+ partition?: Array<unknown>;
65
+ entityName: string;
66
+ indexName: string;
67
+ };
68
+ export declare type EntityQueryResponse<T> = {
69
+ data: Array<KeyValueSchema<T>>;
70
+ cursor?: string;
71
+ };
72
+ export declare type TransactionCondition = EntityQueryFilters;
73
+ export declare type RequestSet<T> = {
74
+ key: string;
75
+ value: T;
76
+ entityName?: string;
77
+ conditions?: TransactionCondition;
78
+ };
79
+ export declare type RequestDelete = {
80
+ key: string;
81
+ entityName?: string;
82
+ conditions?: TransactionCondition;
83
+ };
84
+ export declare type RequestCheck = {
85
+ key: string;
86
+ entityName?: string;
87
+ conditions: TransactionCondition;
88
+ };
89
+ export declare type TransactionRequest<T> = {
90
+ set?: RequestSet<T>[];
91
+ delete?: RequestDelete[];
92
+ check?: RequestCheck[];
93
+ };
94
+ export {};
95
+ //# sourceMappingURL=kvs-api.d.ts.map