Skip to content

Commit

Permalink
Move enums
Browse files Browse the repository at this point in the history
  • Loading branch information
seratch committed Jan 25, 2023
1 parent 547797a commit b589a65
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
4 changes: 2 additions & 2 deletions data_mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import {
} from "https://deno.land/x/deno_slack_api@1.5.0/typed-method-types/apps.ts";
import * as log from "std/log/mod.ts";
import * as func from "./functions.ts";
import { RawExpression } from "./mod.ts";
import { Operator } from "./mod.ts";
import {
DataMapperExpressionQueryArgs,
DataMapperIdQueryArgs,
DataMapperInitArgs,
DataMapperSaveArgs,
Operator,
RawExpression,
SimpleExpression,
} from "./types.ts";

Expand Down
3 changes: 1 addition & 2 deletions data_mapper_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import * as mf from "mock_fetch/mod.ts";
import { assertExists } from "std/testing/asserts.ts";
import { SlackAPI } from "deno_slack_api/mod.ts";
import { DefineDatastore, Schema } from "deno_slack_sdk/mod.ts";
import { DataMapper } from "./mod.ts";
import { Operator } from "./types.ts";
import { DataMapper, Operator } from "./mod.ts";

mf.install();

Expand Down
10 changes: 10 additions & 0 deletions enums.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export enum Operator {
Equal,
LessThan,
LessThanEqual,
GreaterThan,
GreaterThanEqual,
Between, // two args
BeginsWith,
Contains,
}
2 changes: 2 additions & 0 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export {

export { DataMapper } from "./data_mapper.ts";

export { Operator } from "./enums.ts";

export type {
CommonSaveProps,
DataMapperExpressionQueryArgs,
Expand Down
14 changes: 2 additions & 12 deletions types.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as log from "std/log/mod.ts";
import { SlackAPIClient } from "deno_slack_api/types.ts";
import { Operator } from "./enums.ts";

export interface CommonSaveProps {
id?: string;
}

// https://stackoverflow.com/questions/68257379/how-to-omit-optional-properties-from-type
type RequiredFieldsOnly<T> = {
export type RequiredFieldsOnly<T> = {
[K in keyof T as T[K] extends Required<T>[K] ? K : never]: T[K];
};

Expand All @@ -21,17 +22,6 @@ export interface SimpleExpression<Props> {
};
}

export enum Operator {
Equal,
LessThan,
LessThanEqual,
GreaterThan,
GreaterThanEqual,
Between, // two args
BeginsWith,
Contains,
}

export interface RawExpression {
expression: string;
expressionAttributes: Record<string, string>;
Expand Down

0 comments on commit b589a65

Please sign in to comment.