Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improv: update operation value #355

Merged
merged 4 commits into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/blueprints/src/ACL/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class ACL implements IACL, DRP {
return { action: ActionType.Nop };
if (
vertices[0].operation.type === vertices[1].operation.type ||
vertices[0].operation.value !== vertices[1].operation.value
vertices[0].operation.value[0] !== vertices[1].operation.value[0]
)
return { action: ActionType.Nop };

Expand Down
2 changes: 1 addition & 1 deletion packages/blueprints/src/AddWinsSet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class AddWinsSet<T> implements DRP {
vertices[0].operation &&
vertices[1].operation &&
vertices[0].operation?.type !== vertices[1].operation?.type &&
vertices[0].operation?.value === vertices[1].operation?.value
vertices[0].operation?.value[0] === vertices[1].operation?.value[0]
) {
return vertices[0].operation.type === "add"
? { action: ActionType.DropRight }
Expand Down
2 changes: 1 addition & 1 deletion packages/blueprints/src/AddWinsSetWithACL/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export class AddWinsSetWithACL<T> implements DRP {
return { action: ActionType.Nop };
if (
vertices[0].operation.type === vertices[1].operation.type ||
vertices[0].operation.value !== vertices[1].operation.value
vertices[0].operation.value[0] !== vertices[1].operation.value[0]
)
return { action: ActionType.Nop };

Expand Down
2 changes: 1 addition & 1 deletion packages/node/src/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const VERSION = "0.5.2";
export const VERSION = "0.5.3";
5 changes: 2 additions & 3 deletions packages/object/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export class DRPObject implements IDRPObject {
?.trim()
.split(" ")[1];
if (!callerName?.startsWith("Proxy."))
obj.callFn(fullPropKey, args.length === 1 ? args[0] : args);
obj.callFn(fullPropKey, args);
return Reflect.apply(applyTarget, thisArg, args);
},
});
Expand Down Expand Up @@ -253,8 +253,7 @@ export class DRPObject implements IDRPObject {
throw new Error(`${type} is not a function`);
}

const args = Array.isArray(value) ? value : [value];
target[methodName](...args);
target[methodName](...value);
}

// compute the DRP based on all dependencies of the current vertex using partial linearization
Expand Down
60 changes: 30 additions & 30 deletions packages/object/tests/hashgraph.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ describe("HashGraph construction tests", () => {

const linearOps = obj2.hashGraph.linearizeOperations();
expect(linearOps).toEqual([
{ type: "add", value: 2 },
{ type: "add", value: 1 },
{ type: "add", value: [2] },
{ type: "add", value: [1] },
]);
});

Expand All @@ -75,7 +75,7 @@ describe("HashGraph construction tests", () => {
obj1.hashGraph.addVertex(
{
type: "add",
value: 1,
value: [1],
},
[hash],
"",
Expand All @@ -85,7 +85,7 @@ describe("HashGraph construction tests", () => {
expect(obj1.hashGraph.selfCheckConstraints()).toBe(false);

const linearOps = obj1.hashGraph.linearizeOperations();
expect(linearOps).toEqual([{ type: "add", value: 1 }]);
expect(linearOps).toEqual([{ type: "add", value: [1] }]);
});
});

Expand All @@ -112,8 +112,8 @@ describe("HashGraph for AddWinSet tests", () => {

const linearOps = obj1.hashGraph.linearizeOperations();
expect(linearOps).toEqual([
{ type: "add", value: 1 },
{ type: "remove", value: 1 },
{ type: "add", value: [1] },
{ type: "remove", value: [1] },
]);
});

Expand Down Expand Up @@ -141,8 +141,8 @@ describe("HashGraph for AddWinSet tests", () => {

const linearOps = obj1.hashGraph.linearizeOperations();
expect(linearOps).toEqual([
{ type: "add", value: 1 },
{ type: "remove", value: 1 },
{ type: "add", value: [1] },
{ type: "remove", value: [1] },
]);
});

Expand Down Expand Up @@ -170,9 +170,9 @@ describe("HashGraph for AddWinSet tests", () => {

const linearOps = obj1.hashGraph.linearizeOperations();
expect(linearOps).toEqual([
{ type: "add", value: 1 },
{ type: "remove", value: 1 },
{ type: "add", value: 2 },
{ type: "add", value: [1] },
{ type: "remove", value: [1] },
{ type: "add", value: [2] },
]);
});

Expand Down Expand Up @@ -204,9 +204,9 @@ describe("HashGraph for AddWinSet tests", () => {

const linearOps = obj1.hashGraph.linearizeOperations();
expect(linearOps).toEqual([
{ type: "add", value: 1 },
{ type: "remove", value: 1 },
{ type: "add", value: 10 },
{ type: "add", value: [1] },
{ type: "remove", value: [1] },
{ type: "add", value: [10] },
]);
});

Expand Down Expand Up @@ -236,9 +236,9 @@ describe("HashGraph for AddWinSet tests", () => {

const linearOps = obj1.hashGraph.linearizeOperations();
expect(linearOps).toEqual([
{ type: "add", value: 1 },
{ type: "remove", value: 1 },
{ type: "add", value: 2 },
{ type: "add", value: [1] },
{ type: "remove", value: [1] },
{ type: "add", value: [2] },
]);
});

Expand Down Expand Up @@ -289,11 +289,11 @@ describe("HashGraph for AddWinSet tests", () => {

const linearOps = obj1.hashGraph.linearizeOperations();
expect(linearOps).toEqual([
{ type: "add", value: 1 },
{ type: "remove", value: 1 },
{ type: "add", value: 2 },
{ type: "add", value: 3 },
{ type: "remove", value: 1 },
{ type: "add", value: [1] },
{ type: "remove", value: [1] },
{ type: "add", value: [2] },
{ type: "add", value: [3] },
{ type: "remove", value: [1] },
]);
});

Expand Down Expand Up @@ -344,10 +344,10 @@ describe("HashGraph for AddWinSet tests", () => {

const linearOps = obj1.hashGraph.linearizeOperations();
expect(linearOps).toEqual([
{ type: "add", value: 1 },
{ type: "remove", value: 1 },
{ type: "add", value: 3 },
{ type: "add", value: 2 },
{ type: "add", value: [1] },
{ type: "remove", value: [1] },
{ type: "add", value: [3] },
{ type: "add", value: [2] },
]);
});

Expand Down Expand Up @@ -379,9 +379,9 @@ describe("HashGraph for AddWinSet tests", () => {

const linearOps = obj1.hashGraph.linearizeOperations();
expect(linearOps).toEqual([
{ type: "add", value: 1 },
{ type: "add", value: 2 },
{ type: "remove", value: 2 },
{ type: "add", value: [1] },
{ type: "add", value: [2] },
{ type: "remove", value: [2] },
]);
});
});
Expand Down Expand Up @@ -409,7 +409,7 @@ describe("HashGraph for undefined operations tests", () => {

const linearOps = obj2.hashGraph.linearizeOperations();
// Should only have one, since we skipped the undefined operations
expect(linearOps).toEqual([{ type: "add", value: 2 }]);
expect(linearOps).toEqual([{ type: "add", value: [2] }]);
});

test("Test: addToFrontier with undefined operation return Vertex with NoOp operation", () => {
Expand Down
28 changes: 14 additions & 14 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading