-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #702 from jeremydaly/move-conditions-to-actions
Move conditions to actions
- Loading branch information
Showing
70 changed files
with
644 additions
and
381 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import type { NativeAttributeValue } from '@aws-sdk/util-dynamodb' | ||
|
||
import { EntityV2, EntityAction } from 'v1/entity' | ||
import { ConditionParser, Condition } from 'v1/schema/actions/parseCondition' | ||
|
||
const $conditionParser = Symbol('$conditionParser') | ||
type $conditionParser = typeof $conditionParser | ||
|
||
export class EntityConditionParser< | ||
ENTITY extends EntityV2 = EntityV2 | ||
> extends EntityAction<ENTITY> { | ||
static operationName: 'parseCondition'; | ||
[$conditionParser]: ConditionParser<ENTITY['schema']> | ||
|
||
constructor(entity: ENTITY, id = '') { | ||
super(entity) | ||
this[$conditionParser] = new ConditionParser(entity.schema, id) | ||
} | ||
|
||
setId(nextId: string): this { | ||
this[$conditionParser].setId(nextId) | ||
return this | ||
} | ||
|
||
parse = (condition: Condition): this => { | ||
this[$conditionParser].parse(condition) | ||
return this | ||
} | ||
|
||
toCommandOptions(): { | ||
ConditionExpression: string | ||
ExpressionAttributeNames: Record<string, string> | ||
ExpressionAttributeValues: Record<string, NativeAttributeValue> | ||
} { | ||
return this[$conditionParser].toCommandOptions() | ||
} | ||
} | ||
|
||
export type EntityCondition<ENTITY extends EntityV2 = EntityV2> = Condition<ENTITY['schema']> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
...ty/actions/transactions/conditionCheck/conditionCheckParams/parseConditionCheckOptions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/v1/entity/actions/transactions/transactDeleteItem/options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import type { EntityV2 } from 'v1/entity' | ||
import type { ConditionOptions } from 'v1/operations/types/condition' | ||
import type { EntityCondition } from 'v1/entity/actions/parseCondition' | ||
|
||
export type DeleteItemTransactionOptions< | ||
ENTITY extends EntityV2 = EntityV2 | ||
> = ConditionOptions<ENTITY> | ||
export interface DeleteItemTransactionOptions<ENTITY extends EntityV2 = EntityV2> { | ||
condition?: EntityCondition<ENTITY> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
src/v1/entity/actions/transactions/transactPutItem/options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
import type { EntityV2 } from 'v1/entity' | ||
import type { ConditionOptions } from 'v1/operations/types/condition' | ||
import type { EntityCondition } from 'v1/entity/actions/parseCondition' | ||
|
||
export type PutItemTransactionOptions<ENTITY extends EntityV2 = EntityV2> = ConditionOptions<ENTITY> | ||
export interface PutItemTransactionOptions<ENTITY extends EntityV2 = EntityV2> { | ||
condition?: EntityCondition<ENTITY> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
src/v1/entity/actions/transactions/transactUpdateItem/options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import type { EntityV2 } from 'v1/entity' | ||
import type { ConditionOptions } from 'v1/operations/types/condition' | ||
import type { EntityCondition } from 'v1/entity/actions/parseCondition' | ||
|
||
export type UpdateItemTransactionOptions< | ||
ENTITY extends EntityV2 = EntityV2 | ||
> = ConditionOptions<ENTITY> | ||
export interface UpdateItemTransactionOptions<ENTITY extends EntityV2 = EntityV2> { | ||
condition?: EntityCondition<ENTITY> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1 @@ | ||
export type { | ||
Condition, | ||
SchemaCondition, | ||
AnyAttributeCondition, | ||
NonLogicalCondition | ||
} from './condition' | ||
export type { Query } from './query' |
Oops, something went wrong.