@lafken/dynamo 0.10.1

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 (99) hide show
  1. package/LICENCE +21 -0
  2. package/README.md +503 -0
  3. package/lib/index.d.ts +3 -0
  4. package/lib/index.js +19 -0
  5. package/lib/main/index.d.ts +1 -0
  6. package/lib/main/index.js +17 -0
  7. package/lib/main/table/index.d.ts +2 -0
  8. package/lib/main/table/index.js +18 -0
  9. package/lib/main/table/table.d.ts +107 -0
  10. package/lib/main/table/table.js +141 -0
  11. package/lib/main/table/table.types.d.ts +368 -0
  12. package/lib/main/table/table.types.js +15 -0
  13. package/lib/resolver/index.d.ts +1 -0
  14. package/lib/resolver/index.js +17 -0
  15. package/lib/resolver/resolver.d.ts +12 -0
  16. package/lib/resolver/resolver.js +48 -0
  17. package/lib/resolver/resolver.types.d.ts +13 -0
  18. package/lib/resolver/resolver.types.js +2 -0
  19. package/lib/resolver/table/external/external.d.ts +14 -0
  20. package/lib/resolver/table/external/external.js +15 -0
  21. package/lib/resolver/table/internal/internal.d.ts +19 -0
  22. package/lib/resolver/table/internal/internal.js +224 -0
  23. package/lib/resolver/table/table.types.d.ts +4 -0
  24. package/lib/resolver/table/table.types.js +2 -0
  25. package/lib/service/client/client.d.ts +3 -0
  26. package/lib/service/client/client.js +10 -0
  27. package/lib/service/index.d.ts +3 -0
  28. package/lib/service/index.js +19 -0
  29. package/lib/service/query-builder/base/base.d.ts +19 -0
  30. package/lib/service/query-builder/base/base.js +151 -0
  31. package/lib/service/query-builder/base/base.types.d.ts +37 -0
  32. package/lib/service/query-builder/base/base.types.js +2 -0
  33. package/lib/service/query-builder/base/base.utils.d.ts +22 -0
  34. package/lib/service/query-builder/base/base.utils.js +89 -0
  35. package/lib/service/query-builder/batch-write/batch-write.d.ts +15 -0
  36. package/lib/service/query-builder/batch-write/batch-write.js +51 -0
  37. package/lib/service/query-builder/batch-write/batch-write.types.d.ts +9 -0
  38. package/lib/service/query-builder/batch-write/batch-write.types.js +2 -0
  39. package/lib/service/query-builder/bulk-create/bulk-create.d.ts +6 -0
  40. package/lib/service/query-builder/bulk-create/bulk-create.js +26 -0
  41. package/lib/service/query-builder/bulk-create/bulk-create.types.d.ts +4 -0
  42. package/lib/service/query-builder/bulk-create/bulk-create.types.js +2 -0
  43. package/lib/service/query-builder/bulk-delete/bulk-delete.d.ts +6 -0
  44. package/lib/service/query-builder/bulk-delete/bulk-delete.js +27 -0
  45. package/lib/service/query-builder/bulk-delete/bulk-delete.types.d.ts +7 -0
  46. package/lib/service/query-builder/bulk-delete/bulk-delete.types.js +2 -0
  47. package/lib/service/query-builder/create/create.d.ts +6 -0
  48. package/lib/service/query-builder/create/create.js +22 -0
  49. package/lib/service/query-builder/create/create.types.d.ts +6 -0
  50. package/lib/service/query-builder/create/create.types.js +2 -0
  51. package/lib/service/query-builder/delete/delete.d.ts +13 -0
  52. package/lib/service/query-builder/delete/delete.js +33 -0
  53. package/lib/service/query-builder/delete/delete.types.d.ts +7 -0
  54. package/lib/service/query-builder/delete/delete.types.js +2 -0
  55. package/lib/service/query-builder/dynamo-index/dynamo-index.d.ts +15 -0
  56. package/lib/service/query-builder/dynamo-index/dynamo-index.js +90 -0
  57. package/lib/service/query-builder/dynamo-index/dynamo-index.types.d.ts +5 -0
  58. package/lib/service/query-builder/dynamo-index/dynamo-index.types.js +2 -0
  59. package/lib/service/query-builder/find/find.d.ts +13 -0
  60. package/lib/service/query-builder/find/find.js +63 -0
  61. package/lib/service/query-builder/find/find.types.d.ts +8 -0
  62. package/lib/service/query-builder/find/find.types.js +2 -0
  63. package/lib/service/query-builder/find-all/find-all.d.ts +10 -0
  64. package/lib/service/query-builder/find-all/find-all.js +19 -0
  65. package/lib/service/query-builder/find-one/find-one.d.ts +9 -0
  66. package/lib/service/query-builder/find-one/find-one.js +20 -0
  67. package/lib/service/query-builder/index.d.ts +1 -0
  68. package/lib/service/query-builder/index.js +17 -0
  69. package/lib/service/query-builder/query-builder.types.d.ts +243 -0
  70. package/lib/service/query-builder/query-builder.types.js +3 -0
  71. package/lib/service/query-builder/scan/scan.d.ts +15 -0
  72. package/lib/service/query-builder/scan/scan.js +57 -0
  73. package/lib/service/query-builder/scan/scan.types.d.ts +6 -0
  74. package/lib/service/query-builder/scan/scan.types.js +2 -0
  75. package/lib/service/query-builder/update/update.d.ts +15 -0
  76. package/lib/service/query-builder/update/update.js +101 -0
  77. package/lib/service/query-builder/update/update.types.d.ts +6 -0
  78. package/lib/service/query-builder/update/update.types.js +2 -0
  79. package/lib/service/query-builder/update/update.utils.d.ts +11 -0
  80. package/lib/service/query-builder/update/update.utils.js +22 -0
  81. package/lib/service/query-builder/upsert/upsert.d.ts +14 -0
  82. package/lib/service/query-builder/upsert/upsert.js +40 -0
  83. package/lib/service/query-builder/upsert/upsert.types.d.ts +7 -0
  84. package/lib/service/query-builder/upsert/upsert.types.js +2 -0
  85. package/lib/service/repository/index.d.ts +3 -0
  86. package/lib/service/repository/index.js +19 -0
  87. package/lib/service/repository/repository.d.ts +3 -0
  88. package/lib/service/repository/repository.js +89 -0
  89. package/lib/service/repository/repository.types.d.ts +23 -0
  90. package/lib/service/repository/repository.types.js +2 -0
  91. package/lib/service/repository/repository.utils.d.ts +9 -0
  92. package/lib/service/repository/repository.utils.js +17 -0
  93. package/lib/service/transaction/index.d.ts +2 -0
  94. package/lib/service/transaction/index.js +18 -0
  95. package/lib/service/transaction/transaction.d.ts +4 -0
  96. package/lib/service/transaction/transaction.js +38 -0
  97. package/lib/service/transaction/transaction.types.d.ts +5 -0
  98. package/lib/service/transaction/transaction.types.js +2 -0
  99. package/package.json +99 -0
@@ -0,0 +1,9 @@
1
+ import type { BatchWriteItemCommandInput } from '@aws-sdk/client-dynamodb';
2
+ import type { ClassResource } from '@lafken/common';
3
+ import type { QueryBuilderProps } from '../base/base.types';
4
+ import type { Item } from '../query-builder.types';
5
+ export interface BatchWriteBuilderProps<E extends ClassResource> extends QueryBuilderProps<E> {
6
+ items: Partial<Item<E>>[];
7
+ maxAttempt?: number;
8
+ generateBatchCommand: (items: Partial<Item<E>>[]) => BatchWriteItemCommandInput;
9
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import type { ClassResource } from '@lafken/common';
2
+ import { BatchWriteBuilder } from '../batch-write/batch-write';
3
+ import type { BulkCreateBuilderProps } from './bulk-create.types';
4
+ export declare class BulkCreateBuilder<E extends ClassResource> extends BatchWriteBuilder<E> {
5
+ constructor(queryOptions: BulkCreateBuilderProps<E>);
6
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BulkCreateBuilder = void 0;
4
+ const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
5
+ const batch_write_1 = require("../batch-write/batch-write");
6
+ class BulkCreateBuilder extends batch_write_1.BatchWriteBuilder {
7
+ constructor(queryOptions) {
8
+ super({
9
+ ...queryOptions,
10
+ generateBatchCommand: (items) => {
11
+ return {
12
+ RequestItems: {
13
+ [queryOptions.modelProps.name]: items.map((item) => {
14
+ return {
15
+ PutRequest: {
16
+ Item: (0, util_dynamodb_1.marshall)(item),
17
+ },
18
+ };
19
+ }),
20
+ },
21
+ };
22
+ },
23
+ });
24
+ }
25
+ }
26
+ exports.BulkCreateBuilder = BulkCreateBuilder;
@@ -0,0 +1,4 @@
1
+ import type { ClassResource } from '@lafken/common';
2
+ import type { BatchWriteBuilderProps } from '../batch-write/batch-write.types';
3
+ export interface BulkCreateBuilderProps<E extends ClassResource> extends Omit<BatchWriteBuilderProps<E>, 'generateBatchCommand'> {
4
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import type { ClassResource } from '@lafken/common';
2
+ import { BatchWriteBuilder } from '../batch-write/batch-write';
3
+ import type { BulkDeleteBuilderProps } from './bulk-delete.types';
4
+ export declare class BulkDeleteBuilder<E extends ClassResource> extends BatchWriteBuilder<E> {
5
+ constructor(queryOptions: BulkDeleteBuilderProps<E>);
6
+ }
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BulkDeleteBuilder = void 0;
4
+ const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
5
+ const batch_write_1 = require("../batch-write/batch-write");
6
+ class BulkDeleteBuilder extends batch_write_1.BatchWriteBuilder {
7
+ constructor(queryOptions) {
8
+ super({
9
+ ...queryOptions,
10
+ items: queryOptions.keys,
11
+ generateBatchCommand: (items) => {
12
+ return {
13
+ RequestItems: {
14
+ [queryOptions.modelProps.name]: items.map((item) => {
15
+ return {
16
+ DeleteRequest: {
17
+ Key: (0, util_dynamodb_1.marshall)(item),
18
+ },
19
+ };
20
+ }),
21
+ },
22
+ };
23
+ },
24
+ });
25
+ }
26
+ }
27
+ exports.BulkDeleteBuilder = BulkDeleteBuilder;
@@ -0,0 +1,7 @@
1
+ import type { ClassResource } from '@lafken/common';
2
+ import type { TablePartition } from '../../../main/table';
3
+ import type { BatchWriteBuilderProps } from '../batch-write/batch-write.types';
4
+ import type { Item } from '../query-builder.types';
5
+ export interface BulkDeleteBuilderProps<E extends ClassResource> extends Omit<BatchWriteBuilderProps<E>, 'generateBatchCommand' | 'items'> {
6
+ keys: TablePartition<Item<E>>[];
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import type { ClassResource } from '@lafken/common';
2
+ import { UpsertBuilder } from '../upsert/upsert';
3
+ import type { CreateBuilderProps } from './create.types';
4
+ export declare class CreateBuilder<E extends ClassResource> extends UpsertBuilder<E> {
5
+ constructor(queryOptions: CreateBuilderProps<E>);
6
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreateBuilder = void 0;
4
+ const upsert_1 = require("../upsert/upsert");
5
+ class CreateBuilder extends upsert_1.UpsertBuilder {
6
+ constructor(queryOptions) {
7
+ const notExist = {
8
+ notExist: true,
9
+ };
10
+ const filter = {
11
+ [queryOptions.partitionKey]: notExist,
12
+ ...(queryOptions.sortKey ? { [queryOptions.sortKey]: notExist } : {}),
13
+ };
14
+ super({
15
+ ...queryOptions,
16
+ inputProps: {
17
+ condition: filter,
18
+ },
19
+ });
20
+ }
21
+ }
22
+ exports.CreateBuilder = CreateBuilder;
@@ -0,0 +1,6 @@
1
+ import type { ClassResource } from '@lafken/common';
2
+ import type { QueryBuilderProps } from '../base/base.types';
3
+ import type { Item } from '../query-builder.types';
4
+ export interface CreateBuilderProps<E extends ClassResource> extends QueryBuilderProps<E> {
5
+ item: Item<E>;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import { type DeleteItemCommandInput } from '@aws-sdk/client-dynamodb';
2
+ import type { ClassResource } from '@lafken/common';
3
+ import { QueryBuilderBase } from '../base/base';
4
+ import type { DeleteBuilderProps } from './delete.types';
5
+ export declare class DeleteBuilder<E extends ClassResource> extends QueryBuilderBase<E> {
6
+ private queryOptions;
7
+ protected command: DeleteItemCommandInput;
8
+ constructor(queryOptions: DeleteBuilderProps<E>);
9
+ getCommand(): DeleteItemCommandInput;
10
+ then<T>(resolve: (value: boolean) => T, reject: (reason: any) => T): Promise<T>;
11
+ private exec;
12
+ protected prepare(): void;
13
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DeleteBuilder = void 0;
4
+ const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
5
+ const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
6
+ const base_1 = require("../base/base");
7
+ class DeleteBuilder extends base_1.QueryBuilderBase {
8
+ queryOptions;
9
+ command;
10
+ constructor(queryOptions) {
11
+ super(queryOptions);
12
+ this.queryOptions = queryOptions;
13
+ this.prepare();
14
+ }
15
+ getCommand() {
16
+ return this.command;
17
+ }
18
+ then(resolve, reject) {
19
+ return this.exec().then(resolve, reject);
20
+ }
21
+ async exec() {
22
+ const command = new client_dynamodb_1.DeleteItemCommand(this.command);
23
+ await this.queryOptions.client.send(command);
24
+ return true;
25
+ }
26
+ prepare() {
27
+ this.command = {
28
+ TableName: this.queryOptions.modelProps.name,
29
+ Key: (0, util_dynamodb_1.marshall)(this.queryOptions.key),
30
+ };
31
+ }
32
+ }
33
+ exports.DeleteBuilder = DeleteBuilder;
@@ -0,0 +1,7 @@
1
+ import type { ClassResource } from '@lafken/common';
2
+ import type { TablePartition } from '../../../main/table';
3
+ import type { QueryBuilderProps } from '../base/base.types';
4
+ import type { Item } from '../query-builder.types';
5
+ export interface DeleteBuilderProps<E extends ClassResource> extends QueryBuilderProps<E> {
6
+ key: TablePartition<Item<E>>;
7
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import type { DynamoIndex, LocalIndex } from '../../../main';
2
+ import type { QueryProps } from '../query-builder.types';
3
+ import type { GlobalIndexProperty } from './dynamo-index.types';
4
+ export declare class DynamoIndexes {
5
+ private partitionKey;
6
+ private sortKey?;
7
+ private localIndexes;
8
+ private globalIndexes;
9
+ private indexByName;
10
+ constructor(indexes: DynamoIndex<any>[], partitionKey: string, sortKey?: string | undefined);
11
+ getIndex(props: QueryProps<any>): LocalIndex<any> | GlobalIndexProperty | undefined;
12
+ private getLocalIndex;
13
+ private getGlobalIndex;
14
+ private compareIndexAttributes;
15
+ }
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DynamoIndexes = void 0;
4
+ class DynamoIndexes {
5
+ partitionKey;
6
+ sortKey;
7
+ localIndexes = [];
8
+ globalIndexes = [];
9
+ indexByName = {};
10
+ constructor(indexes, partitionKey, sortKey) {
11
+ this.partitionKey = partitionKey;
12
+ this.sortKey = sortKey;
13
+ for (const index of indexes) {
14
+ if (index.type === 'local') {
15
+ this.indexByName[index.name] = index;
16
+ this.localIndexes.push(index);
17
+ continue;
18
+ }
19
+ const globalIndex = {
20
+ ...index,
21
+ type: 'global',
22
+ partitionKey: Array.isArray(index.partitionKey)
23
+ ? new Set([...index.partitionKey])
24
+ : new Set([index.partitionKey]),
25
+ sortKey: !index.sortKey
26
+ ? new Set()
27
+ : Array.isArray(index.sortKey)
28
+ ? new Set([...index.sortKey])
29
+ : new Set([index.sortKey]),
30
+ };
31
+ this.indexByName[index.name] = globalIndex;
32
+ this.globalIndexes.push(globalIndex);
33
+ }
34
+ }
35
+ getIndex(props) {
36
+ const { keyCondition: { partition, sort }, indexName, } = props;
37
+ if (indexName) {
38
+ const index = this.indexByName[indexName];
39
+ if (!index) {
40
+ throw new Error(`the index "${indexName}" does not exist`);
41
+ }
42
+ return index;
43
+ }
44
+ const partitionKeys = Object.keys(partition);
45
+ const sortKeys = Object.keys(sort || {});
46
+ if (partitionKeys.length > 1 || sortKeys.length > 1) {
47
+ return this.getGlobalIndex(new Set(partitionKeys), new Set(sortKeys));
48
+ }
49
+ if (this.partitionKey === partitionKeys[0] && this.sortKey !== sortKeys[0]) {
50
+ const index = this.getLocalIndex(sortKeys[0]);
51
+ if (index) {
52
+ return index;
53
+ }
54
+ }
55
+ if (this.partitionKey === partitionKeys[0] &&
56
+ (!this.sortKey || sortKeys.length === 0 || this.sortKey === sortKeys[0])) {
57
+ return;
58
+ }
59
+ return this.getGlobalIndex(new Set(partitionKeys), new Set(sortKeys));
60
+ }
61
+ getLocalIndex(sortKey) {
62
+ const index = this.localIndexes.find((index) => index.sortKey === sortKey);
63
+ return index;
64
+ }
65
+ getGlobalIndex(partitionKeys, sortKeys) {
66
+ const index = this.globalIndexes.find((index) => {
67
+ if (index.partitionKey.size !== partitionKeys.size) {
68
+ return false;
69
+ }
70
+ if (this.compareIndexAttributes(index.partitionKey, partitionKeys) &&
71
+ this.compareIndexAttributes(index.sortKey, sortKeys)) {
72
+ return true;
73
+ }
74
+ return false;
75
+ });
76
+ if (!index) {
77
+ throw new Error('no index found for the selected attributes');
78
+ }
79
+ return index;
80
+ }
81
+ compareIndexAttributes(indexKeys, queryKeys) {
82
+ for (const item of queryKeys) {
83
+ if (!indexKeys.has(item)) {
84
+ return false;
85
+ }
86
+ }
87
+ return true;
88
+ }
89
+ }
90
+ exports.DynamoIndexes = DynamoIndexes;
@@ -0,0 +1,5 @@
1
+ import type { GlobalIndex } from '../../../main';
2
+ export interface GlobalIndexProperty extends Omit<GlobalIndex<any>, 'partitionKey' | 'sortKey'> {
3
+ partitionKey: Set<string>;
4
+ sortKey: Set<string>;
5
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,13 @@
1
+ import { type QueryCommandInput } from '@aws-sdk/client-dynamodb';
2
+ import type { ClassResource } from '@lafken/common';
3
+ import { QueryBuilderBase } from '../base/base';
4
+ import type { QueryResponse } from '../query-builder.types';
5
+ import type { FindBuilderProps } from './find.types';
6
+ export declare class FindBuilder<E extends ClassResource> extends QueryBuilderBase<E> {
7
+ protected queryOptions: FindBuilderProps<E>;
8
+ protected command: QueryCommandInput;
9
+ constructor(queryOptions: FindBuilderProps<E>);
10
+ getCommand(): QueryCommandInput;
11
+ protected find(): void;
12
+ protected runQuery(input: QueryCommandInput, data?: Partial<E[]>): Promise<QueryResponse<E>>;
13
+ }
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindBuilder = void 0;
4
+ const client_dynamodb_1 = require("@aws-sdk/client-dynamodb");
5
+ const util_dynamodb_1 = require("@aws-sdk/util-dynamodb");
6
+ const base_1 = require("../base/base");
7
+ class FindBuilder extends base_1.QueryBuilderBase {
8
+ queryOptions;
9
+ command;
10
+ constructor(queryOptions) {
11
+ super(queryOptions);
12
+ this.queryOptions = queryOptions;
13
+ this.find();
14
+ }
15
+ getCommand() {
16
+ return this.command;
17
+ }
18
+ find() {
19
+ const { limit, cursor, keyCondition, filter, projection = 'ALL', sortDirection = 'asc', } = this.queryOptions.inputProps;
20
+ const index = this.queryOptions.indexes.getIndex(this.queryOptions.inputProps);
21
+ const keyConditionExpression = this.getKeyConditionExpression(keyCondition, index);
22
+ let filterExpression;
23
+ if (filter) {
24
+ const expression = this.getFilterExpression(filter || {});
25
+ filterExpression = expression;
26
+ }
27
+ this.command = {
28
+ TableName: this.queryOptions.modelProps.name,
29
+ IndexName: index?.name,
30
+ KeyConditionExpression: keyConditionExpression,
31
+ FilterExpression: filterExpression,
32
+ ExclusiveStartKey: cursor ? (0, util_dynamodb_1.marshall)(cursor) : undefined,
33
+ Limit: limit,
34
+ ScanIndexForward: sortDirection === 'asc',
35
+ ProjectionExpression: projection === 'ALL' ? undefined : projection.join(', '),
36
+ ...this.getAttributesAndNames(),
37
+ };
38
+ }
39
+ async runQuery(input, data = []) {
40
+ const command = new client_dynamodb_1.QueryCommand(input);
41
+ const { Items = [], LastEvaluatedKey } = await this.queryOptions.client.send(command);
42
+ const resultData = Items.map((item) => (0, util_dynamodb_1.unmarshall)(item));
43
+ if (input.Limit === 1) {
44
+ return {
45
+ data: [resultData[0]],
46
+ cursor: LastEvaluatedKey ? (0, util_dynamodb_1.unmarshall)(LastEvaluatedKey) : undefined,
47
+ };
48
+ }
49
+ const items = data.concat(resultData);
50
+ if (LastEvaluatedKey && (!input.Limit || items.length < input.Limit)) {
51
+ return this.runQuery({
52
+ ...input,
53
+ ExclusiveStartKey: LastEvaluatedKey,
54
+ Limit: input.Limit ? input.Limit - items.length : undefined,
55
+ }, items);
56
+ }
57
+ return {
58
+ data: items,
59
+ cursor: LastEvaluatedKey ? (0, util_dynamodb_1.unmarshall)(LastEvaluatedKey) : undefined,
60
+ };
61
+ }
62
+ }
63
+ exports.FindBuilder = FindBuilder;
@@ -0,0 +1,8 @@
1
+ import type { ClassResource } from '@lafken/common';
2
+ import type { QueryBuilderProps } from '../base/base.types';
3
+ import type { DynamoIndexes } from '../dynamo-index/dynamo-index';
4
+ import type { QueryProps } from '../query-builder.types';
5
+ export interface FindBuilderProps<E extends ClassResource> extends QueryBuilderProps<E> {
6
+ inputProps: QueryProps<E>;
7
+ indexes: DynamoIndexes;
8
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import type { ClassResource } from '@lafken/common';
2
+ import { FindBuilder } from '../find/find';
3
+ import type { FindBuilderProps } from '../find/find.types';
4
+ import type { QueryResponse } from '../query-builder.types';
5
+ export declare class FindAllBuilder<E extends ClassResource> extends FindBuilder<E> {
6
+ protected queryOptions: FindBuilderProps<E>;
7
+ constructor(queryOptions: FindBuilderProps<E>);
8
+ then<T>(resolve: (value: QueryResponse<E>) => T, reject: (reason: any) => T): Promise<T>;
9
+ private exec;
10
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindAllBuilder = void 0;
4
+ const find_1 = require("../find/find");
5
+ class FindAllBuilder extends find_1.FindBuilder {
6
+ queryOptions;
7
+ constructor(queryOptions) {
8
+ super(queryOptions);
9
+ this.queryOptions = queryOptions;
10
+ this.find();
11
+ }
12
+ then(resolve, reject) {
13
+ return this.exec().then(resolve, reject);
14
+ }
15
+ async exec() {
16
+ return this.runQuery(this.command);
17
+ }
18
+ }
19
+ exports.FindAllBuilder = FindAllBuilder;
@@ -0,0 +1,9 @@
1
+ import type { ClassResource } from '@lafken/common';
2
+ import { FindBuilder } from '../find/find';
3
+ import type { FindBuilderProps } from '../find/find.types';
4
+ export declare class FindOneBuilder<E extends ClassResource> extends FindBuilder<E> {
5
+ protected queryOptions: FindBuilderProps<E>;
6
+ constructor(queryOptions: FindBuilderProps<E>);
7
+ then<T>(resolve: (value: InstanceType<E> | undefined) => T, reject: (reason: any) => T): Promise<T>;
8
+ private exec;
9
+ }
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FindOneBuilder = void 0;
4
+ const find_1 = require("../find/find");
5
+ class FindOneBuilder extends find_1.FindBuilder {
6
+ queryOptions;
7
+ constructor(queryOptions) {
8
+ super(queryOptions);
9
+ this.queryOptions = queryOptions;
10
+ this.find();
11
+ }
12
+ then(resolve, reject) {
13
+ return this.exec().then(resolve, reject);
14
+ }
15
+ async exec() {
16
+ const { data } = await this.runQuery(this.command);
17
+ return data?.[0];
18
+ }
19
+ }
20
+ exports.FindOneBuilder = FindOneBuilder;
@@ -0,0 +1 @@
1
+ export * from './query-builder.types';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./query-builder.types"), exports);