diff --git a/packages/core/src/core.ts b/packages/core/src/core.ts index 726c5d5..efb461a 100644 --- a/packages/core/src/core.ts +++ b/packages/core/src/core.ts @@ -69,7 +69,7 @@ export type Dependencies = { multicast: Multicast; broadcast: Broadcast; call: Call; - peel: Peel; + naked: Naked; }; /** @@ -106,7 +106,7 @@ export type Colocally = < args: Args, ) => Promise; -export type Peel = ( +export type Naked = ( mlv: MultiplyLocated, ) => T; @@ -385,7 +385,7 @@ export class Projector { multicast: multicast(childTag), broadcast: broadcast(childTag), call: call(childTag), - peel: (v) => v.getValue(key), + naked: (v) => v.getValue(key), }), args, ); @@ -489,7 +489,7 @@ export class Projector { } }; - const peel: Peel = (cv: MultiplyLocated) => + const naked: Naked = (cv: MultiplyLocated) => cv.getValue(key); const call: (t: Tag) => Call = @@ -511,7 +511,7 @@ export class Projector { call: call(childTag), multicast: multicast(childTag), colocally: colocally(childTag), - peel: peel, + naked: naked, }), a, ); @@ -525,7 +525,7 @@ export class Projector { call: call(tag), multicast: multicast(tag), colocally: colocally(tag), - peel: peel, + naked: naked, }), args.map((x) => new Located(x, key)) as any, ); @@ -621,7 +621,7 @@ export class Runner { multicast: multicast, broadcast: broadcast, call: call, - peel: peel, + naked: naked, }), args, ); @@ -660,13 +660,13 @@ export class Runner { call: call, multicast: multicast, colocally: colocally, - peel: peel, + naked: naked, }), a, ); return ret; }; - const peel: Peel = (cv: MultiplyLocated) => + const naked: Naked = (cv: MultiplyLocated) => cv.getValue(key); const ret = await choreography( @@ -677,7 +677,7 @@ export class Runner { call: call, multicast: multicast, colocally: colocally, - peel: peel, + naked: naked, }, args.map((x) => new Located(x, key)) as any, ); diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index b496167..f98293c 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -4,7 +4,7 @@ export type { Locally, Comm, Colocally, - Peel, + Naked, Multicast, Broadcast, Call, diff --git a/packages/eslint-plugin-choreography-ts/src/no-outside-choreographic-operator.ts b/packages/eslint-plugin-choreography-ts/src/no-outside-choreographic-operator.ts index 82a7c46..ae6e0fe 100644 --- a/packages/eslint-plugin-choreography-ts/src/no-outside-choreographic-operator.ts +++ b/packages/eslint-plugin-choreography-ts/src/no-outside-choreographic-operator.ts @@ -13,7 +13,7 @@ import ts from "typescript"; type MessageIDs = "error" | "suggestion"; -const operators = /^(locally|colocally|multicast|broadcast|comm|call|peel)$/; +const operators = /^(locally|colocally|multicast|broadcast|comm|call|naked)$/; const choreographySelector = `VariableDeclaration[kind = "const"] > VariableDeclarator`; const functionSelector = `${choreographySelector} > :matches(ArrowFunctionExpression, FunctionExpression)`; diff --git a/packages/eslint-plugin-choreography-ts/tests/no-outside-choreographic-operator.test.ts b/packages/eslint-plugin-choreography-ts/tests/no-outside-choreographic-operator.test.ts index c1c9d02..7f6395c 100644 --- a/packages/eslint-plugin-choreography-ts/tests/no-outside-choreographic-operator.test.ts +++ b/packages/eslint-plugin-choreography-ts/tests/no-outside-choreographic-operator.test.ts @@ -25,8 +25,8 @@ ruleTester.run("no-outside-choreographic-operator", noOutsideOperatorRule, { }) => { const [deliveryDateAtBuyer] = await colocally( ["buyer1", "seller"], - async ({ locally, comm, peel }) => { - const sharedDecision = peel(decision); + async ({ locally, comm, naked }) => { + const sharedDecision = naked(decision); if (sharedDecision) { const deliveryDateAtSeller = await locally( "seller", @@ -102,7 +102,7 @@ ruleTester.run("no-outside-choreographic-operator", noOutsideOperatorRule, { const [deliveryDateAtBuyer] = await colocally( ["buyer1", "seller"], async (arg) => { - const sharedDecision = peel(decision); + const sharedDecision = naked(decision); if (sharedDecision) { const deliveryDateAtSeller = await locally( "seller", @@ -115,7 +115,7 @@ ruleTester.run("no-outside-choreographic-operator", noOutsideOperatorRule, { output: null, // assert that no autofix is suggested errors: [ { - // error for missing `peel` operator, with no suggestions + // error for missing `naked` operator, with no suggestions messageId: "error", suggestions: null, }, @@ -142,7 +142,7 @@ ruleTester.run("no-outside-choreographic-operator", noOutsideOperatorRule, { await colocally( ["buyer1", "seller"], async function (arg) { - const sharedDecision = peel(decision); + const sharedDecision = naked(decision); await locally("seller", () => sharedDecision); return []; }, @@ -172,8 +172,8 @@ ruleTester.run("no-outside-choreographic-operator", noOutsideOperatorRule, { }) => { const [deliveryDateAtBuyer] = await colocally( ["buyer1", "seller"], - async ({ peel }) => { - const sharedDecision = peel(decision); + async ({ naked }) => { + const sharedDecision = naked(decision); if (sharedDecision) { const deliveryDateAtSeller = await locally( "seller", @@ -191,8 +191,8 @@ ruleTester.run("no-outside-choreographic-operator", noOutsideOperatorRule, { }) => { const [deliveryDateAtBuyer] = await colocally( ["buyer1", "seller"], - async ({ peel, locally }) => { - const sharedDecision = peel(decision); + async ({ naked, locally }) => { + const sharedDecision = naked(decision); if (sharedDecision) { const deliveryDateAtSeller = await locally( "seller", @@ -216,8 +216,8 @@ ruleTester.run("no-outside-choreographic-operator", noOutsideOperatorRule, { }) => { const [deliveryDateAtBuyer] = await colocally( ["buyer1", "seller"], - async ({ peel, locally }) => { - const sharedDecision = peel(decision); + async ({ naked, locally }) => { + const sharedDecision = naked(decision); if (sharedDecision) { const deliveryDateAtSeller = await locally( "seller", @@ -244,7 +244,7 @@ ruleTester.run("no-outside-choreographic-operator", noOutsideOperatorRule, { const [deliveryDateAtBuyer] = await colocally( ["buyer1", "seller"], async ({}) => { - const sharedDecision = peel(decision); + const sharedDecision = naked(decision); } ) };`, @@ -256,8 +256,8 @@ ruleTester.run("no-outside-choreographic-operator", noOutsideOperatorRule, { }) => { const [deliveryDateAtBuyer] = await colocally( ["buyer1", "seller"], - async ({ peel }) => { - const sharedDecision = peel(decision); + async ({ naked }) => { + const sharedDecision = naked(decision); } ) };`, diff --git a/packages/examples/src/bookseller2/bookseller2.ts b/packages/examples/src/bookseller2/bookseller2.ts index 4e578a3..563fcfd 100644 --- a/packages/examples/src/bookseller2/bookseller2.ts +++ b/packages/examples/src/bookseller2/bookseller2.ts @@ -67,8 +67,8 @@ export const bookseller: ( const decision = await multicast("buyer1", ["seller"], decisionAtBuyer); const [deliveryDateAtBuyer] = await colocally( ["buyer1", "seller"], - async ({ locally, comm, peel }) => { - const sharedDecision = peel(decision); + async ({ locally, comm, naked }) => { + const sharedDecision = naked(decision); if (sharedDecision) { const deliveryDateAtSeller = await locally( "seller", diff --git a/packages/examples/src/kvs/kvs.ts b/packages/examples/src/kvs/kvs.ts index 920b226..0cd475a 100644 --- a/packages/examples/src/kvs/kvs.ts +++ b/packages/examples/src/kvs/kvs.ts @@ -70,8 +70,8 @@ export const primaryBackupReplicationStrategy: ReplicationStrategy< // forward request to backup if mutating await colocally( ["primary", "backup"], - async ({ locally, comm, peel }) => { - if (peel(isPut)) { + async ({ locally, comm, naked }) => { + if (naked(isPut)) { const requestAtBackup = await comm( "primary", "backup",