Skip to content

Commit

Permalink
fix: runs in strict mode aka deno v0.34.0 (closes #16)
Browse files Browse the repository at this point in the history
  • Loading branch information
chiefbiiko committed Mar 3, 2020
1 parent 3ca4800 commit ba9e890
Show file tree
Hide file tree
Showing 21 changed files with 503 additions and 973 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/cloud_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ jobs:
TABLE_NAME: testing_table
steps:
- name: clone repo
uses: actions/checkout@v1.0.0
uses: actions/checkout@v2.0.0
- name: install deno
uses: denolib/setup-deno@v1.1.0
uses: denolib/setup-deno@v1.2.0
- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v1
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/local_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: clone repo
uses: actions/checkout@v1.0.0
uses: actions/checkout@v2.0.0
- name: install deno
uses: denolib/setup-deno@v1.1.0
uses: denolib/setup-deno@v1.2.0
- name: run tests
run: deno run --allow-env ./test/signv4.ts
test_local:
name: test dynamodb local
runs-on: ubuntu-latest
steps:
- name: clone repo
uses: actions/checkout@v1.0.0
uses: actions/checkout@v2.0.0
- name: install deno
uses: denolib/setup-deno@v1.1.0
uses: denolib/setup-deno@v1.2.0
- name: start a local dynamodb
run: curl -fsSL https://denopkg.com/chiefbiiko/[email protected]/start_db.sh | bash
- name: sleep 2 allow db startup
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
dynamodb_local_latest.zip
dynamodb_local_latest
dynamodb_local_latest*
shared-local-instance.db*
14 changes: 9 additions & 5 deletions api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import {
property /*, string as stringUtil*/
} from "../util.ts";

// NOTE: 2 run in ts strict-mode (bypassing TS7009)
const _Collection: any = Collection
const _Operation: any = Operation

// var Paginator = require('./paginator');
// var ResourceWaiter = require('./resource_waiter');

export function Api(api: Doc = {}, options: Doc = {}) {
export function Api(this: any, api: Doc = {}, options: Doc = {}) {
const self: any = this;
// api = api || {};
// options = options || {};
Expand Down Expand Up @@ -38,7 +42,7 @@ export function Api(api: Doc = {}, options: Doc = {}) {
api.metadata.serviceAbbreviation || api.metadata.serviceFullName;

if (!name) {
return null;
return "";
}

name = name.replace(/^Amazon|AWS\s*|\(.*|\s+|\W+/g, "");
Expand All @@ -59,11 +63,11 @@ export function Api(api: Doc = {}, options: Doc = {}) {
property(
this,
"operations",
new Collection(
new _Collection(
api.operations,
options,
function(name: string, operation: Doc): any {
return new Operation(name, operation, options);
return new _Operation(name, operation, options);
} /*, stringUtil.lowerFirst*/,
addEndpointOperation
)
Expand All @@ -72,7 +76,7 @@ export function Api(api: Doc = {}, options: Doc = {}) {
property(
this,
"shapes",
new Collection(api.shapes, options, function(
new _Collection(api.shapes, options, function(
name: string,
shape: Doc
): any {
Expand Down
2 changes: 2 additions & 0 deletions api/collection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { Doc, memoizedProperty, noop } from "../util.ts";

function memoize(
this: any,
name: string,
value: any,
factory: (
Expand All @@ -16,6 +17,7 @@ function memoize(
}

export function Collection(
this: any,
iterable: any,
options: Doc,
factory: (
Expand Down
9 changes: 4 additions & 5 deletions api/mod.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Doc } from "../util.ts";
import { Api } from "./api.ts";

const spec: Doc = JSON.parse(`
const _Api: any = Api;

export const API: any = new _Api(JSON.parse(`
{
"version": "2.0",
"metadata": {
Expand Down Expand Up @@ -2228,6 +2229,4 @@ const spec: Doc = JSON.parse(`
}
}
}
`);

export const API: any = new Api(spec);
`));
8 changes: 4 additions & 4 deletions api/operation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Shape } from "./shape.ts";
import { Doc, memoizedProperty, property } from "../util.ts";
// import { Doc} from "../types.ts"

export function Operation(name: string, operation: Doc, options: Doc = {}) {
export function Operation(this: any, name: string, operation: Doc, options: Doc = {}) {
const self: any = this;
// options = options || {};

Expand Down Expand Up @@ -47,7 +47,7 @@ export function Operation(name: string, operation: Doc, options: Doc = {}) {

memoizedProperty(this, "errors", function(): any[] {
if (!operation.errors) {
return null;
return [];
}

return operation.errors.map((error: any): any =>
Expand Down Expand Up @@ -83,8 +83,8 @@ export function Operation(name: string, operation: Doc, options: Doc = {}) {
}

return Object.entries(self.input.members)
.filter(([_, value]: [string, Doc]): boolean => value.isIdempotent)
.map(([key, _]: [string, Doc]): string => key);
.filter(([_, value]: [string, any]): boolean => value.isIdempotent)
.map(([key, _]: [string, any]): string => key);

// for (const name in members) {
// if (!members.hasOwnProperty(name)) {
Expand Down
Loading

0 comments on commit ba9e890

Please sign in to comment.