From 4e488170a69f723e401bf7c6df7fe168e19843f0 Mon Sep 17 00:00:00 2001 From: Chris Rybicki Date: Fri, 19 Apr 2024 18:38:19 -0400 Subject: [PATCH] chore: use indexing syntax --- bedrock/README.md | 2 +- bedrock/joke.w | 4 ++-- bedrock/package.json | 2 +- cognito/package.json | 2 +- cognito/platform/sim.w | 12 ++++++------ containers/package.json | 2 +- containers/tfaws-eks.w | 14 +++++++------- containers/tfaws-vpc.w | 8 ++++---- containers/values.w | 6 +++--- containers/workload.tfaws.w | 2 +- dynamodb/README.md | 4 ++-- dynamodb/package.json | 2 +- dynamodb/tests/compatibility.gsi.test.w | 9 +++++---- dynamodb/tests/compatibility.query.test.w | 12 ++++++------ dynamodb/tests/delete.test.w | 2 +- dynamodb/tests/put.test.w | 2 +- dynamodb/tests/query.test.w | 12 ++++++------ dynamodb/tests/scan.test.w | 4 ++-- dynamodb/tests/transact-write.test.w | 8 ++++---- eventbridge/lib.test.w | 8 ++++---- eventbridge/package.json | 2 +- eventbridge/platform/sim/bus.w | 4 ++-- eventbridge/platform/sim/eventbridge.w | 4 ++-- github/lib.w | 6 +++--- github/ngrok/ngrok.w | 8 ++++---- github/package.json | 2 +- github/simutils/simutils.w | 2 +- github/utils/lowkeys.w | 4 ++-- jwt/lib.test.w | 6 +++--- jwt/package.json | 2 +- messagefanout/lib.test.w | 10 +++++----- messagefanout/package.json | 2 +- openai/openai.w | 2 +- openai/package.json | 2 +- postgres/lib.test.w | 2 +- postgres/package.json | 2 +- websockets/README.md | 2 +- websockets/package.json | 2 +- 38 files changed, 91 insertions(+), 90 deletions(-) diff --git a/bedrock/README.md b/bedrock/README.md index eb07999b..38064be3 100644 --- a/bedrock/README.md +++ b/bedrock/README.md @@ -38,7 +38,7 @@ pub class JokeMaker { anthropic_version: "bedrock-2023-05-31" }); - return res.get("completion").asStr(); + return res["completion"].asStr(); } } ``` diff --git a/bedrock/joke.w b/bedrock/joke.w index 7bf3e413..74623f99 100644 --- a/bedrock/joke.w +++ b/bedrock/joke.w @@ -20,6 +20,6 @@ pub class JokeMaker { anthropic_version: "bedrock-2023-05-31" }); - return res.get("completion").asStr(); + return res["completion"].asStr(); } -} \ No newline at end of file +} diff --git a/bedrock/package.json b/bedrock/package.json index 4f98e580..a79a652a 100644 --- a/bedrock/package.json +++ b/bedrock/package.json @@ -1,7 +1,7 @@ { "name": "@winglibs/bedrock", "description": "A Wing library for Amazon Bedrock", - "version": "0.0.5", + "version": "0.0.6", "author": { "name": "Eyal Keren", "email": "eyalk@wing.cloud" diff --git a/cognito/package.json b/cognito/package.json index 2b085cbb..1fa63fd5 100644 --- a/cognito/package.json +++ b/cognito/package.json @@ -1,6 +1,6 @@ { "name": "@winglibs/cognito", - "version": "0.0.7", + "version": "0.0.8", "description": "A wing library to work with AWS Cognito", "author": { "name": "Elad Cohen", diff --git a/cognito/platform/sim.w b/cognito/platform/sim.w index ab5a1b8f..a5887c9c 100644 --- a/cognito/platform/sim.w +++ b/cognito/platform/sim.w @@ -108,13 +108,13 @@ pub class Cognito_sim impl types.ICognito { for entry in api.handlers.entries() { let handler = entry.value; let func: cloud.Function = handler.func; - let route = handler.mapping.eventProps.subscriptionProps.routes.at(0); + let route = handler.mapping.eventProps.subscriptionProps.routes[0]; if route.pathPattern == path && route.method == method.uppercase() { - let pathJson = MutJson api.apiSpec.get("paths").get(path); + let pathJson = MutJson api.apiSpec["paths"][path]; pathJson.set(method, unsafeCast(nil)); let api2: Json = unsafeCast(this.api); - let callable: ICallable = unsafeCast(api2?.get(method)); + let callable: ICallable = unsafeCast(api2[method]); callable.call(this.api, path, inflight (req: cloud.ApiRequest) => { if req.headers?.tryGet("authorization") != "Bearer sim-auth-token" { if this.counter.peek() % 2 == 0 { @@ -154,7 +154,7 @@ pub class Cognito_sim impl types.ICognito { this.table.update(email, { "email": email, - "password": row!.get("password").asStr(), + "password": row!["password"].asStr(), "confirmed": true, }); } @@ -165,11 +165,11 @@ pub class Cognito_sim impl types.ICognito { throw "User not found"; } - if row!.get("email").asStr() != email || row!.get("password").asStr() != password { + if row!["email"].asStr() != email || row!["password"].asStr() != password { throw "Invalid credentials"; } - if !row!.get("confirmed").asBool() { + if !row!["confirmed"].asBool() { throw "User not confirmed"; } diff --git a/containers/package.json b/containers/package.json index c862651c..b9a98c55 100644 --- a/containers/package.json +++ b/containers/package.json @@ -1,6 +1,6 @@ { "name": "@winglibs/containers", - "version": "0.0.27", + "version": "0.0.28", "description": "Container support for Wing", "repository": { "type": "git", diff --git a/containers/tfaws-eks.w b/containers/tfaws-eks.w index 3ea80539..a0052537 100644 --- a/containers/tfaws-eks.w +++ b/containers/tfaws-eks.w @@ -107,9 +107,9 @@ pub class Cluster extends ClusterBase impl ICluster { } return ClusterAttributes { - name: values.Values.get("eks.cluster_name"), - certificate: values.Values.get("eks.certificate"), - endpoint: values.Values.get("eks.endpoint"), + name: values.Values["eks.cluster_name"], + certificate: values.Values["eks.certificate"], + endpoint: values.Values["eks.endpoint"], }; } @@ -167,11 +167,11 @@ pub class Cluster extends ClusterBase impl ICluster { this._attributes = { name: clusterName, - certificate: cluster.get("cluster_certificate_authority_data"), - endpoint: cluster.get("cluster_endpoint"), + certificate: cluster["cluster_certificate_authority_data"], + endpoint: cluster["cluster_endpoint"], }; - this._oidcProviderArn = cluster.get("oidc_provider_arn"); + this._oidcProviderArn = cluster["oidc_provider_arn"]; // output the cluster name new cdktf.TerraformOutput(value: this._attributes.name, description: "eks.cluster_name") as "eks.cluster_name"; @@ -216,7 +216,7 @@ pub class Cluster extends ClusterBase impl ICluster { "app.kubernetes.io/component"=> "controller" }, annotations: { - "eks.amazonaws.com/role-arn" => lbRole.get("iam_role_arn"), + "eks.amazonaws.com/role-arn" => lbRole["iam_role_arn"], "eks.amazonaws.com/sts-regional-endpoints" => "true" }, } diff --git a/containers/tfaws-vpc.w b/containers/tfaws-vpc.w index 52c0bfe2..93ecaadb 100644 --- a/containers/tfaws-vpc.w +++ b/containers/tfaws-vpc.w @@ -38,8 +38,8 @@ pub class Vpc { } ); - this.id = vpc.get("vpc_id"); - this.privateSubnets = vpc.get("private_subnets"); - this.publicSubnets = vpc.get("public_subnets"); + this.id = vpc["vpc_id"]; + this.privateSubnets = vpc["private_subnets"]; + this.publicSubnets = vpc["public_subnets"]; } -} \ No newline at end of file +} diff --git a/containers/values.w b/containers/values.w index 3893be90..e717579a 100644 --- a/containers/values.w +++ b/containers/values.w @@ -23,8 +23,8 @@ pub class Values { if values != "undefined" { for v in values.split(",") { let kv = v.split("="); - let key = kv.at(0); - let value = kv.at(1); + let key = kv[0]; + let value = kv[1]; all.set(key, value); } } @@ -48,4 +48,4 @@ pub class Values { throw "Missing platform value '{key}' (use --values or -v)"; } } -} \ No newline at end of file +} diff --git a/containers/workload.tfaws.w b/containers/workload.tfaws.w index 79f1c41b..cfb6ba98 100644 --- a/containers/workload.tfaws.w +++ b/containers/workload.tfaws.w @@ -41,7 +41,7 @@ pub class Workload_tfaws { let envVariables = MutMap{}; for k in env.keys() { - if let v = env.get(k) { + if let v = env[k] { envVariables.set(k, plus.EnvValue.fromValue(v)); } } diff --git a/dynamodb/README.md b/dynamodb/README.md index a1e33d38..f9c595e8 100644 --- a/dynamodb/README.md +++ b/dynamodb/README.md @@ -44,8 +44,8 @@ test "put and query" { ExpressionAttributeValues: {":id": "1"}, ); assert(response.Count == 1); - assert(response.Items.at(0).get("id").asStr() == "1"); - assert(response.Items.at(0).get("body").asStr() == "hello"); + assert(response.Items[0]["id"].asStr() == "1"); + assert(response.Items[0]["body"].asStr() == "hello"); } ``` diff --git a/dynamodb/package.json b/dynamodb/package.json index 23463b2d..03212bf2 100644 --- a/dynamodb/package.json +++ b/dynamodb/package.json @@ -1,6 +1,6 @@ { "name": "@winglibs/dynamodb", - "version": "0.1.6", + "version": "0.1.7", "description": "DynamoDB library for Wing", "author": { "name": "Cristian PallarΓ©s", diff --git a/dynamodb/tests/compatibility.gsi.test.w b/dynamodb/tests/compatibility.gsi.test.w index e3791b61..89a122eb 100644 --- a/dynamodb/tests/compatibility.gsi.test.w +++ b/dynamodb/tests/compatibility.gsi.test.w @@ -42,8 +42,8 @@ test "GlobalSecondaryIndex" { ]; for i in idCreated { - let id = i.get("id").asStr(); - let createAt = i.get("createdAt").asNum(); + let id = i["id"].asStr(); + let createAt = i["createdAt"].asNum(); table.put({ Item: { @@ -71,7 +71,8 @@ test "GlobalSecondaryIndex" { // returns all items order by id desc let ids = ["zuegksw", "pdkeruf", "dirnfhw", "azjekfw"]; for i in 0..ids.length { - assert(items.Items.at(i).get("id") == ids.at(i)); + let x = items.Items[i]["id"]; + assert(items.Items[i]["id"] == ids[i]); } let itemsCreatedAtIndex = table.query( @@ -91,6 +92,6 @@ test "GlobalSecondaryIndex" { // returns all items order by createdAt desc let idsOrderByCreatedAt = ["azjekfw", "pdkeruf", "dirnfhw", "zuegksw"]; for i in 0..idsOrderByCreatedAt.length { - assert(itemsCreatedAtIndex.Items.at(i).get("id") == idsOrderByCreatedAt.at(i)); + assert(itemsCreatedAtIndex.Items[i]["id"] == idsOrderByCreatedAt[i]); } } diff --git a/dynamodb/tests/compatibility.query.test.w b/dynamodb/tests/compatibility.query.test.w index 832b820c..d58a7391 100644 --- a/dynamodb/tests/compatibility.query.test.w +++ b/dynamodb/tests/compatibility.query.test.w @@ -33,10 +33,10 @@ test "query" { ); assert(result.Count == 2); - assert(result.Items.at(0).get("k1") == "key1"); - assert(result.Items.at(0).get("k2") == "value1"); - assert(result.Items.at(0).get("k3") == "other-value1"); - assert(result.Items.at(1).get("k1") == "key1"); - assert(result.Items.at(1).get("k2") == "value2"); - assert(result.Items.at(1).get("k3") == "other-value2"); + assert(result.Items[0]["k1"] == "key1"); + assert(result.Items[0]["k2"] == "value1"); + assert(result.Items[0]["k3"] == "other-value1"); + assert(result.Items[1]["k1"] == "key1"); + assert(result.Items[1]["k2"] == "value2"); + assert(result.Items[1]["k3"] == "other-value2"); } diff --git a/dynamodb/tests/delete.test.w b/dynamodb/tests/delete.test.w index 7ac4cf26..d23918aa 100644 --- a/dynamodb/tests/delete.test.w +++ b/dynamodb/tests/delete.test.w @@ -37,5 +37,5 @@ test "delete (`returnValues=ALL_OLD`)" { ReturnValues: "ALL_OLD", ); - assert(response.Attributes?.get("body")?.asStr() == "hello world"); + assert(response.Attributes?.tryGet("body")?.asStr() == "hello world"); } diff --git a/dynamodb/tests/put.test.w b/dynamodb/tests/put.test.w index f16cee6e..25b79a72 100644 --- a/dynamodb/tests/put.test.w +++ b/dynamodb/tests/put.test.w @@ -39,5 +39,5 @@ test "put (`returnValues=ALL_OLD`)" { ReturnValues: "ALL_OLD", ); - assert(response.Attributes?.get("body")?.asStr() == "hello world"); + assert(response.Attributes?.tryGet("body")?.asStr() == "hello world"); } diff --git a/dynamodb/tests/query.test.w b/dynamodb/tests/query.test.w index ada43cc4..cebb7ca9 100644 --- a/dynamodb/tests/query.test.w +++ b/dynamodb/tests/query.test.w @@ -44,10 +44,10 @@ test "query" { ExpressionAttributeValues: {":id": "1"}, ); assert(response.Count == 2); - assert(response.Items.at(0).get("id").asStr() == "1"); - assert(response.Items.at(0).get("sk").asStr() == "a"); - assert(response.Items.at(0).get("body").asStr() == "hello a"); - assert(response.Items.at(1).get("id").asStr() == "1"); - assert(response.Items.at(1).get("sk").asStr() == "b"); - assert(response.Items.at(1).get("body").asStr() == "hello b"); + assert(response.Items[0]["id"].asStr() == "1"); + assert(response.Items[0]["sk"].asStr() == "a"); + assert(response.Items[0]["body"].asStr() == "hello a"); + assert(response.Items[1]["id"].asStr() == "1"); + assert(response.Items[1]["sk"].asStr() == "b"); + assert(response.Items[1]["body"].asStr() == "hello b"); } diff --git a/dynamodb/tests/scan.test.w b/dynamodb/tests/scan.test.w index e18085bf..7de12456 100644 --- a/dynamodb/tests/scan.test.w +++ b/dynamodb/tests/scan.test.w @@ -21,6 +21,6 @@ test "scan" { let response = table.scan(); assert(response.Count == 1); - assert(response.Items.at(0).get("id").asStr() == "1"); - assert(response.Items.at(0).get("body").asStr() == "hello"); + assert(response.Items[0]["id"].asStr() == "1"); + assert(response.Items[0]["body"].asStr() == "hello"); } diff --git a/dynamodb/tests/transact-write.test.w b/dynamodb/tests/transact-write.test.w index 55307544..01ddb5bb 100644 --- a/dynamodb/tests/transact-write.test.w +++ b/dynamodb/tests/transact-write.test.w @@ -27,8 +27,8 @@ test "transactWrite (put)" { let response = table.scan(); assert(response.Count == 1); - assert(response.Items.at(0).get("id").asStr() == "1"); - assert(response.Items.at(0).get("body").asStr() == "hello"); + assert(response.Items[0]["id"].asStr() == "1"); + assert(response.Items[0]["body"].asStr() == "hello"); } test "transactWrite (delete)" { @@ -93,8 +93,8 @@ test "transactWrite (update)" { let response = table.scan(); assert(response.Count == 1); - assert(response.Items.at(0).get("id").asStr() == "1"); - assert(response.Items.at(0).get("body").asStr() == "world"); + assert(response.Items[0]["id"].asStr() == "1"); + assert(response.Items[0]["body"].asStr() == "world"); } test "transactWrite (conditionCheck)" { diff --git a/eventbridge/lib.test.w b/eventbridge/lib.test.w index 3e607059..199b575c 100644 --- a/eventbridge/lib.test.w +++ b/eventbridge/lib.test.w @@ -68,7 +68,7 @@ test "publish to eventbridge" { log("after wait"); let published = types.Event.fromJson(github.bucket.getJson("test-0")); expect.equal("pull-request.created", published.detailType); - expect.equal("test", published.resources.at(0)); + expect.equal("test", published.resources[0]); expect.equal("github.com", published.source); expect.equal(0, env.bucket.list().length); @@ -94,7 +94,7 @@ test "publish to eventbridge" { // cant deserialize events coming from queue (see https://github.com/winglang/wing/issues/3686) let published2 = env.bucket.getJson("environment"); - expect.equal("myTest.check", published2.get("detail-type")); - expect.equal("test", published2.get("resources").getAt(0)); - expect.equal("myTest", published2.get("source")); + expect.equal("myTest.check", published2["detail-type"]); + expect.equal("test", published2["resources"][0]); + expect.equal("myTest", published2["source"]); } diff --git a/eventbridge/package.json b/eventbridge/package.json index daeb2205..5510687d 100644 --- a/eventbridge/package.json +++ b/eventbridge/package.json @@ -1,7 +1,7 @@ { "name": "@winglibs/eventbridge", "description": "Amazon EventBridge library for Wing", - "version": "0.1.1", + "version": "0.1.2", "repository": { "type": "git", "url": "https://github.com/winglang/winglibs.git", diff --git a/eventbridge/platform/sim/bus.w b/eventbridge/platform/sim/bus.w index f31e9a8a..507d25f6 100644 --- a/eventbridge/platform/sim/bus.w +++ b/eventbridge/platform/sim/bus.w @@ -23,7 +23,7 @@ pub class EventBridgeBus { try { let parsedEventRaw = Json.parse(event); let jsonEvent = MutJson { - "detailType": parsedEventRaw.get("detail-type").asStr(), + "detailType": parsedEventRaw["detail-type"].asStr(), }; for e in Json.entries(parsedEventRaw) { @@ -76,4 +76,4 @@ pub class EventBridgeBus { this.topic.publish(stringified); } } -} \ No newline at end of file +} diff --git a/eventbridge/platform/sim/eventbridge.w b/eventbridge/platform/sim/eventbridge.w index 29a08dce..0a390394 100644 --- a/eventbridge/platform/sim/eventbridge.w +++ b/eventbridge/platform/sim/eventbridge.w @@ -29,7 +29,7 @@ pub class Bus impl types.IBus { let onMessageHandler = bus.subscribe(inflight (event) => { let json: MutJson = event; // make it look like it came from AWS - json.set("detail-type", json.get("detailType")); + json.set("detail-type", json["detailType"]); json.set("detailType", unsafeCast(nil)); queue.push(Json.stringify(json)); }, pattern); @@ -50,4 +50,4 @@ pub class Bus impl types.IBus { pub inflight putEvents(events: Array): void { this.bus.putEvents(events); } -} \ No newline at end of file +} diff --git a/github/lib.w b/github/lib.w index c84bf849..0a512417 100644 --- a/github/lib.w +++ b/github/lib.w @@ -101,15 +101,15 @@ pub class ProbotApp { throw "getVerifyProps: missing id header"; } - let id = lowkeysHeaders.get("x-github-delivery"); + let id = lowkeysHeaders["x-github-delivery"]; if !lowkeysHeaders.has("x-github-event") { throw "getVerifyProps: missing name header"; } - let name = lowkeysHeaders.get("x-github-event"); + let name = lowkeysHeaders["x-github-event"]; - let signature = lowkeysHeaders.get("x-hub-signature-256"); + let signature = lowkeysHeaders["x-hub-signature-256"]; if let payload = req.body { return { diff --git a/github/ngrok/ngrok.w b/github/ngrok/ngrok.w index 9efc2461..e494a7b7 100644 --- a/github/ngrok/ngrok.w +++ b/github/ngrok/ngrok.w @@ -37,11 +37,11 @@ pub class Ngrok { while retries > 0 { try { let json = Json.parse(http.get("http://127.0.0.1:{ngrokAPIPort}/api/tunnels").body); - for tunnel in Json.values(json.get("tunnels")) { - let address = tunnel.get("config").get("addr").asStr(); + for tunnel in Json.values(json["tunnels"]) { + let address = tunnel["config"]["addr"].asStr(); log("Checking {address}"); if address == props.url { - state.set("url", tunnel.get("public_url").asStr()); + state.set("url", tunnel["public_url"].asStr()); return nil; } } @@ -56,4 +56,4 @@ pub class Ngrok { }); urlRetriever.node.addDependency(ngrok); } -} \ No newline at end of file +} diff --git a/github/package.json b/github/package.json index d297e45d..9f2981c1 100644 --- a/github/package.json +++ b/github/package.json @@ -1,7 +1,7 @@ { "name": "@winglibs/github", "description": "A Wing library for GitHub Probot", - "version": "0.0.9", + "version": "0.0.10", "author": { "name": "Elad Cohen", "email": "eladc@wing.cloud" diff --git a/github/simutils/simutils.w b/github/simutils/simutils.w index a8677749..256a04bb 100644 --- a/github/simutils/simutils.w +++ b/github/simutils/simutils.w @@ -22,7 +22,7 @@ pub class Service { let env = commonEnv.copyMut(); if let propsEnv = props.env { for key in propsEnv.keys() { - env.set(key, propsEnv.get(key)); + env.set(key, propsEnv[key]); } } let child = Service.spawn( diff --git a/github/utils/lowkeys.w b/github/utils/lowkeys.w index 4b77db66..8078528b 100644 --- a/github/utils/lowkeys.w +++ b/github/utils/lowkeys.w @@ -3,9 +3,9 @@ pub inflight class LowkeysMap { let res = MutMap{}; for key in map.keys() { - res.set(key.lowercase(), map.get(key)); + res.set(key.lowercase(), map[key]); } return res.copy(); } -} \ No newline at end of file +} diff --git a/jwt/lib.test.w b/jwt/lib.test.w index c80c77ec..238c2db1 100644 --- a/jwt/lib.test.w +++ b/jwt/lib.test.w @@ -6,11 +6,11 @@ test "sign and verify" { let id = util.nanoid(); let token = jwt.sign({ foo: id }, "shhhhh"); let decoded1 = jwt.verify(token, secret: "shhhhh"); - expect.equal(decoded1.get("foo").asStr(), id); + expect.equal(decoded1["foo"].asStr(), id); let token2 = jwt.sign({ foo: id }, "shhhhh", algorithm: "HS256"); let decoded2 = jwt.verify(token2, secret: "shhhhh", options: { algorithms: ["HS256"] }); - expect.equal(decoded2.get("foo").asStr(), id); + expect.equal(decoded2["foo"].asStr(), id); } test "sign with notBefore" { @@ -41,5 +41,5 @@ test "sign and decode" { let id = util.nanoid(); let token = jwt.sign({ foo: id }, "shhhhh"); let decoded1 = jwt.decode(token, complete: true); - expect.equal(decoded1.get("payload").get("foo").asStr(), id); + expect.equal(decoded1["payload"]["foo"].asStr(), id); } diff --git a/jwt/package.json b/jwt/package.json index ae52de18..3c00cf7e 100644 --- a/jwt/package.json +++ b/jwt/package.json @@ -1,7 +1,7 @@ { "name": "@winglibs/jwt", "description": "Wing library for JWT authentication", - "version": "0.0.4", + "version": "0.0.5", "repository": { "type": "git", "url": "https://github.com/winglang/winglibs.git", diff --git a/messagefanout/lib.test.w b/messagefanout/lib.test.w index 4ea98d0e..d0fb6176 100644 --- a/messagefanout/lib.test.w +++ b/messagefanout/lib.test.w @@ -22,10 +22,10 @@ fanout.addConsumer(inflight (msg: str) => { }, name: "second"); test "message fanout" { - fanout.publish("hello πŸ‘‹"); - - util.sleep(10s); + fanout.publish("hello πŸ‘‹"); + + util.sleep(10s); - assert(table.get("first").get("message") == "first hello πŸ‘‹"); - assert(table.get("second").get("message") == "second hello πŸ‘‹"); + assert(table.get("first")["message"] == "first hello πŸ‘‹"); + assert(table.get("second")["message"] == "second hello πŸ‘‹"); } diff --git a/messagefanout/package.json b/messagefanout/package.json index 3dd492c7..10c47411 100644 --- a/messagefanout/package.json +++ b/messagefanout/package.json @@ -1,7 +1,7 @@ { "name": "@winglibs/messagefanout", "description": "Message fanout library for Wing", - "version": "0.0.3", + "version": "0.0.4", "repository": { "type": "git", "url": "https://github.com/winglang/winglibs.git", diff --git a/openai/openai.w b/openai/openai.w index f7008f09..d63dceb8 100644 --- a/openai/openai.w +++ b/openai/openai.w @@ -76,7 +76,7 @@ pub class OpenAI { messages: [ { role: "user", content: prompt } ] }); - return resp.get("choices").getAt(0).get("message").get("content").asStr(); + return resp["choices"][0]["message"]["content"].asStr(); } extern "./openai.js" pub static inflight createNewInflightClient(apiKey: str, org: str?): IClient; diff --git a/openai/package.json b/openai/package.json index 1294544e..b07165ba 100644 --- a/openai/package.json +++ b/openai/package.json @@ -1,7 +1,7 @@ { "name": "@winglibs/openai", "description": "OpenAI library for Wing", - "version": "0.0.4", + "version": "0.0.5", "repository": { "type": "git", "url": "https://github.com/winglang/winglibs.git", diff --git a/postgres/lib.test.w b/postgres/lib.test.w index 280bb030..3deb06f4 100644 --- a/postgres/lib.test.w +++ b/postgres/lib.test.w @@ -6,5 +6,5 @@ let db = new l.Database(name: "test", pgVersion: 15); test "run a simple query" { let result = db.query("SELECT 1 as one, 2 as two;"); - expect.equal(result.at(0), {one: 1, two: 2}); + expect.equal(result[0], {one: 1, two: 2}); } diff --git a/postgres/package.json b/postgres/package.json index f75a4824..79c07dbf 100644 --- a/postgres/package.json +++ b/postgres/package.json @@ -1,6 +1,6 @@ { "name": "@winglibs/postgres", - "version": "0.1.0", + "version": "0.1.1", "description": "Postgres support for Wing", "repository": { "type": "git", diff --git a/websockets/README.md b/websockets/README.md index 8c80557a..08b8d082 100644 --- a/websockets/README.md +++ b/websockets/README.md @@ -54,7 +54,7 @@ wb.onDisconnect(inflight(id: str): void => { wb.onMessage(inflight (id: str, body: str): void => { let connections = tb.scan(); for item in connections.items { - wb.sendMessage(str.fromJson(item.get("connectionId")), body); + wb.sendMessage(str.fromJson(item["connectionId"]), body); } }); diff --git a/websockets/package.json b/websockets/package.json index 13998f9d..cf98056a 100644 --- a/websockets/package.json +++ b/websockets/package.json @@ -1,7 +1,7 @@ { "name": "@winglibs/websockets", "description": "WebSocket library for Wing", - "version": "0.3.6", + "version": "0.3.7", "repository": { "type": "git", "url": "https://github.com/winglang/winglibs.git",