Skip to content

Commit

Permalink
Trace invalidation from start to finish (#710)
Browse files Browse the repository at this point in the history
  • Loading branch information
dwwoelfel authored Jan 14, 2025
1 parent a970c83 commit 1f61651
Show file tree
Hide file tree
Showing 15 changed files with 354 additions and 206 deletions.
24 changes: 22 additions & 2 deletions client/sandbox/react-nextjs/pages/play/color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import config from "../../config";
const schema = i.schema({
entities: {
colors: i.entity({ color: i.string() }),
}
},
});

const db = init({ ...config, schema });
Expand All @@ -16,6 +16,16 @@ function App() {

const selectId = "4d39508b-9ee2-48a3-b70d-8192d9c5a059";

const colorOptions = ["green", "blue", "purple"];

function nextColor(c: string): string {
const i = colorOptions.indexOf(c);
if (i === -1) {
return colorOptions[0];
}
return colorOptions[(i + 1) % colorOptions.length];
}

function Main() {
useEffect(() => {
(async () => {
Expand All @@ -35,7 +45,7 @@ function Main() {
<div className="space-y-4">
<h1>Hi! pick your favorite color</h1>
<div className="space-x-4">
{["green", "blue", "purple"].map((c) => {
{colorOptions.map((c) => {
return (
<button
onClick={() => {
Expand All @@ -48,6 +58,16 @@ function Main() {
</button>
);
})}
<button
className={`bg-white p-2`}
onClick={() => {
db.transact(
tx.colors[selectId].update({ color: nextColor(color) }),
);
}}
>
Cycle
</button>
</div>
</div>
</div>
Expand Down
87 changes: 2 additions & 85 deletions server/flags-config/instant.perms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,92 +6,9 @@ const rules = {
create: "false",
},
},
"rate-limited-apps": {
$default: {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
},
},
"storage-whitelist": {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
},
},
"friend-emails": {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
},
},
"view-checks": {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
},
},
"power-user-emails": {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
},
},
"test-emails": {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
},
},
"promo-emails": {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
},
},
"use-patch-presence": {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
},
},
"drop-refresh-spam": {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
},
},
custodian: {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
},
},
"team-emails": {
allow: {
view: "false",
create: "false",
delete: "false",
update: "false",
$default: "false",
},
},
};
Expand Down
7 changes: 5 additions & 2 deletions server/flags-config/instant.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ const graph = i.graph(
$users: i.entity({
email: i.string().unique().indexed(),
}),
"e2e-logging": i.entity({
"invalidator-rate": i.number(),
}),
"drop-refresh-spam": i.entity({
"default-value": i.boolean(),
"disabled-apps": i.any(),
Expand All @@ -29,7 +32,7 @@ const graph = i.graph(
email: i.string(),
}),
"rate-limited-apps": i.entity({
appId: i.string().unique()
appId: i.string().unique(),
}),
"storage-whitelist": i.entity({
appId: i.string().unique().indexed(),
Expand All @@ -47,7 +50,7 @@ const graph = i.graph(
// For example, if `posts` should have many `comments`.
// More in the docs:
// https://www.instantdb.com/docs/schema#defining-links
{},
{}
);

export default graph;
4 changes: 2 additions & 2 deletions server/flags-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"dev:push": "INSTANT_CLI_DEV=1 instant-cli push"
},
"dependencies": {
"@instantdb/core": "^0.14.29",
"instant-cli": "^0.14.29"
"@instantdb/core": "^0.17.7",
"instant-cli": "^0.17.7"
}
}
98 changes: 89 additions & 9 deletions server/flags-config/pnpm-lock.yaml

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

1 change: 1 addition & 0 deletions server/refinery/rules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Samplers:
FieldList:
- root.name
- root.op
- root.entropy
Loading

0 comments on commit 1f61651

Please sign in to comment.