diff --git a/.vscode/settings.json b/.vscode/settings.json index d5288243..55d62472 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -86,75 +86,6 @@ "files.autoSave": "afterDelay", "files.autoSaveDelay": 1000, "files.exclude": { - ".DS_Store": true, - ".changeset": true, - ".dockerignore": true, - ".editorconfig": true, - ".env": true, - ".env.example": true, - ".env.prod": true, - ".env.prod.example": true, - ".git": true, - ".gitattributes": true, - ".github": true, - ".gitignore": true, - ".markdownlintignore": true, - ".markuplintrc.cjs": true, - ".nhost": true, - ".npmrc": true, - ".secrets": true, - ".secrets.example": true, - ".secrets.prod": true, - ".secrets.prod.example": true, - ".textlintignore": true, - ".turbo": true, - ".vercelignore": true, - ".vscode": true, - "CHANGELOG.md": true, - "CODE_OF_CONDUCT.md": true, - "CONTRIBUTING.md": true, - "DEVELOPERS.md": true, - "Dockerfile": true, - "LICENSE": true, - "Makefile": true, - "README.md": true, - "biome.jsonc": true, - "bun.Dockerfile": true, - "bun.lockb": true, - "cog.toml": true, - "compose.override.yml": true, - "compose.yml": true, - "config": true, - "config.yaml": true, - "degit.json": true, - "docs": true, - "flake.nix": true, - "functions": true, - "infra": true, - "nhost": true, - "node_modules": true, - "package.json": true, - "packages": true, - "patches": true, - "pnpm-lock.yaml": true, - "pnpm-workspace.yaml": true, - "scripts": true, - "turbo.json": true, - "vercel.json": true, - "vitest.config.ts": true, - "vitest.workspaces.ts": true, - "apps/console-fb": true, - "apps/console-sc": true, - "apps/docs": true, - "apps/playground": true, - "apps/web": true, - "packages/assets": true, - "packages/biome-config": true, - "packages/role-houdini": true, - "packages/skeleton-ui": true, - "packages/typescript-config": true, - "packages/ui": true, - "packages/utils": true, "**/.git": true, "**/.DS_Store": true, ".idea": true, @@ -387,81 +318,5 @@ "[yaml]": { "editor.defaultFormatter": "redhat.vscode-yaml" }, - "redhat.telemetry.enabled": false, - "monorepoFocusWorkspace.internal": { - "spectacular": { - "managedFilesIgnoreEntries": [ - ".DS_Store", - ".changeset", - ".dockerignore", - ".editorconfig", - ".env", - ".env.example", - ".env.prod", - ".env.prod.example", - ".git", - ".gitattributes", - ".github", - ".gitignore", - ".markdownlintignore", - ".markuplintrc.cjs", - ".nhost", - ".npmrc", - ".secrets", - ".secrets.example", - ".secrets.prod", - ".secrets.prod.example", - ".textlintignore", - ".turbo", - ".vercelignore", - ".vscode", - "CHANGELOG.md", - "CODE_OF_CONDUCT.md", - "CONTRIBUTING.md", - "DEVELOPERS.md", - "Dockerfile", - "LICENSE", - "Makefile", - "README.md", - "biome.jsonc", - "bun.Dockerfile", - "bun.lockb", - "cog.toml", - "compose.override.yml", - "compose.yml", - "config", - "config.yaml", - "degit.json", - "docs", - "flake.nix", - "functions", - "infra", - "nhost", - "node_modules", - "package.json", - "packages", - "patches", - "pnpm-lock.yaml", - "pnpm-workspace.yaml", - "scripts", - "turbo.json", - "vercel.json", - "vitest.config.ts", - "vitest.workspaces.ts", - "apps/console-fb", - "apps/console-sc", - "apps/docs", - "apps/playground", - "apps/web", - "packages/assets", - "packages/biome-config", - "packages/role-houdini", - "packages/skeleton-ui", - "packages/typescript-config", - "packages/ui", - "packages/utils" - ], - "focusedWorkspace": "console" - } - } + "redhat.telemetry.enabled": false } diff --git a/apps/console-fb/schema.graphql b/apps/console-fb/schema.graphql index aa35f441..02ca96de 100644 --- a/apps/console-fb/schema.graphql +++ b/apps/console-fb/schema.graphql @@ -3829,6 +3829,29 @@ type query_root { """fetch data from the table: "subject_type" using primary key columns""" subject_type_by_pk(value: String!): subject_type + """ + fetch data from the table: "test_rule" + """ + test_rule( + """distinct select on columns""" + distinct_on: [test_rule_select_column!] + + """limit the number of rows returned""" + limit: Int + + """skip the first n rows. Use only with order_by""" + offset: Int + + """sort the rows by one or more columns""" + order_by: [test_rule_order_by!] + + """filter the rows returned""" + where: test_rule_bool_exp + ): [test_rule!]! + + """fetch data from the table: "test_rule" using primary key columns""" + test_rule_by_pk(a: uuid!): test_rule + """fetch data from the table: "auth.users" using primary key columns""" user(id: uuid!): users @@ -5072,6 +5095,43 @@ type subscription_root { where: subject_type_bool_exp ): [subject_type!]! + """ + fetch data from the table: "test_rule" + """ + test_rule( + """distinct select on columns""" + distinct_on: [test_rule_select_column!] + + """limit the number of rows returned""" + limit: Int + + """skip the first n rows. Use only with order_by""" + offset: Int + + """sort the rows by one or more columns""" + order_by: [test_rule_order_by!] + + """filter the rows returned""" + where: test_rule_bool_exp + ): [test_rule!]! + + """fetch data from the table: "test_rule" using primary key columns""" + test_rule_by_pk(a: uuid!): test_rule + + """ + fetch data from the table in a streaming manner: "test_rule" + """ + test_rule_stream( + """maximum number of rows returned in a single batch""" + batch_size: Int! + + """cursor to stream the results returned by the query""" + cursor: [test_rule_stream_cursor_input]! + + """filter the rows returned""" + where: test_rule_bool_exp + ): [test_rule!]! + """fetch data from the table: "auth.users" using primary key columns""" user(id: uuid!): users @@ -5204,6 +5264,71 @@ type subscription_root { ): [users!]! } +"""created by nithin, just for testing""" +type test_rule { + a: uuid! + b: timestamptz! + c: Boolean! + d: Int! +} + +""" +Boolean expression to filter rows from the table "test_rule". All fields are combined with a logical 'AND'. +""" +input test_rule_bool_exp { + _and: [test_rule_bool_exp!] + _not: test_rule_bool_exp + _or: [test_rule_bool_exp!] + a: uuid_comparison_exp + b: timestamptz_comparison_exp + c: Boolean_comparison_exp + d: Int_comparison_exp +} + +"""Ordering options when selecting data from "test_rule".""" +input test_rule_order_by { + a: order_by + b: order_by + c: order_by + d: order_by +} + +""" +select columns of table "test_rule" +""" +enum test_rule_select_column { + """column name""" + a + + """column name""" + b + + """column name""" + c + + """column name""" + d +} + +""" +Streaming cursor of the table "test_rule" +""" +input test_rule_stream_cursor_input { + """Stream column input with initial value""" + initial_value: test_rule_stream_cursor_value_input! + + """cursor ordering""" + ordering: cursor_ordering +} + +"""Initial value of the column from where the streaming should start""" +input test_rule_stream_cursor_value_input { + a: uuid + b: timestamptz + c: Boolean + d: Int +} + scalar timestamp """ diff --git a/apps/console/schema.graphql b/apps/console/schema.graphql index aa35f441..02ca96de 100644 --- a/apps/console/schema.graphql +++ b/apps/console/schema.graphql @@ -3829,6 +3829,29 @@ type query_root { """fetch data from the table: "subject_type" using primary key columns""" subject_type_by_pk(value: String!): subject_type + """ + fetch data from the table: "test_rule" + """ + test_rule( + """distinct select on columns""" + distinct_on: [test_rule_select_column!] + + """limit the number of rows returned""" + limit: Int + + """skip the first n rows. Use only with order_by""" + offset: Int + + """sort the rows by one or more columns""" + order_by: [test_rule_order_by!] + + """filter the rows returned""" + where: test_rule_bool_exp + ): [test_rule!]! + + """fetch data from the table: "test_rule" using primary key columns""" + test_rule_by_pk(a: uuid!): test_rule + """fetch data from the table: "auth.users" using primary key columns""" user(id: uuid!): users @@ -5072,6 +5095,43 @@ type subscription_root { where: subject_type_bool_exp ): [subject_type!]! + """ + fetch data from the table: "test_rule" + """ + test_rule( + """distinct select on columns""" + distinct_on: [test_rule_select_column!] + + """limit the number of rows returned""" + limit: Int + + """skip the first n rows. Use only with order_by""" + offset: Int + + """sort the rows by one or more columns""" + order_by: [test_rule_order_by!] + + """filter the rows returned""" + where: test_rule_bool_exp + ): [test_rule!]! + + """fetch data from the table: "test_rule" using primary key columns""" + test_rule_by_pk(a: uuid!): test_rule + + """ + fetch data from the table in a streaming manner: "test_rule" + """ + test_rule_stream( + """maximum number of rows returned in a single batch""" + batch_size: Int! + + """cursor to stream the results returned by the query""" + cursor: [test_rule_stream_cursor_input]! + + """filter the rows returned""" + where: test_rule_bool_exp + ): [test_rule!]! + """fetch data from the table: "auth.users" using primary key columns""" user(id: uuid!): users @@ -5204,6 +5264,71 @@ type subscription_root { ): [users!]! } +"""created by nithin, just for testing""" +type test_rule { + a: uuid! + b: timestamptz! + c: Boolean! + d: Int! +} + +""" +Boolean expression to filter rows from the table "test_rule". All fields are combined with a logical 'AND'. +""" +input test_rule_bool_exp { + _and: [test_rule_bool_exp!] + _not: test_rule_bool_exp + _or: [test_rule_bool_exp!] + a: uuid_comparison_exp + b: timestamptz_comparison_exp + c: Boolean_comparison_exp + d: Int_comparison_exp +} + +"""Ordering options when selecting data from "test_rule".""" +input test_rule_order_by { + a: order_by + b: order_by + c: order_by + d: order_by +} + +""" +select columns of table "test_rule" +""" +enum test_rule_select_column { + """column name""" + a + + """column name""" + b + + """column name""" + c + + """column name""" + d +} + +""" +Streaming cursor of the table "test_rule" +""" +input test_rule_stream_cursor_input { + """Stream column input with initial value""" + initial_value: test_rule_stream_cursor_value_input! + + """cursor ordering""" + ordering: cursor_ordering +} + +"""Initial value of the column from where the streaming should start""" +input test_rule_stream_cursor_value_input { + a: uuid + b: timestamptz + c: Boolean + d: Int +} + scalar timestamp """ diff --git a/apps/console/src/lib/api/index.ts b/apps/console/src/lib/api/index.ts new file mode 100644 index 00000000..90f6e792 --- /dev/null +++ b/apps/console/src/lib/api/index.ts @@ -0,0 +1 @@ +export { loadOptions } from './svelte_select_fetches'; diff --git a/apps/console/src/lib/links.ts b/apps/console/src/lib/links.ts index 0d776dbe..2b44796d 100644 --- a/apps/console/src/lib/links.ts +++ b/apps/console/src/lib/links.ts @@ -15,6 +15,7 @@ export const menuNavLinks: MenuNavLinks = { list: [ { href: '/policies', label: 'Policies', keywords: 'svelte, sirens, license, release', preload: 'false' }, { href: '/rules', label: 'Golden Rules', keywords: 'start, install, cli, tailwind, themes, stylesheets' }, + { href: '/testrule', label: 'testing Rules', keywords: 'start, install, cli, tailwind, themes, stylesheets' }, ], }, { diff --git a/apps/console/src/lib/schema/rule.ts b/apps/console/src/lib/schema/rule.ts index 4816bc61..a8c3fbe5 100644 --- a/apps/console/src/lib/schema/rule.ts +++ b/apps/console/src/lib/schema/rule.ts @@ -21,6 +21,7 @@ export const ruleSchema = z.object({ throttleRate: z.coerce.number().min(0).max(100).optional().default(80), weight: z.coerce.number().min(0).max(1000).optional().default(1000), shared: z.boolean().optional().default(false), + active: z.boolean().optional().default(true), }); export type RuleSchema = typeof ruleSchema; diff --git a/apps/console/src/lib/utils/logger.ts b/apps/console/src/lib/utils/logger.ts new file mode 100644 index 00000000..1fb1094b --- /dev/null +++ b/apps/console/src/lib/utils/logger.ts @@ -0,0 +1,48 @@ +export enum LogLevel { + off = 0, + Debug, + Error, + Warning, + Info +} + +export class Logger { + static level = LogLevel.Debug; + + private source: string; + + /** + * Enables production mode. + * Sets logging level to LogLevel.Warning. + */ + static enableProductionMode() { + Logger.level = LogLevel.Warning; + } + + constructor(component: string) { + this.source = component; + } + + public debug(...data: unknown[]): void { + this.log(console.info, LogLevel.Debug, data); + } + + public info(...data: unknown[]): void { + this.log(console.info, LogLevel.Info, data); + } + + public warn(...data: unknown[]): void { + this.log(console.warn, LogLevel.Warning, data); + } + + public error(...data: unknown[]): void { + this.log(console.error, LogLevel.Error, data); + } + + private log = (fun: () => void, level: LogLevel, objects: unknown[]): void => { + if (level >= Logger.level) { + const log = this.source ? [`[${this.source}]`].concat(objects as string[]) : objects; + fun.apply(console, log); + } + }; +} diff --git a/apps/console/src/routes/(app)/rules/create/+page.svelte b/apps/console/src/routes/(app)/rules/create/+page.svelte index aa7da02b..337dabd5 100644 --- a/apps/console/src/routes/(app)/rules/create/+page.svelte +++ b/apps/console/src/routes/(app)/rules/create/+page.svelte @@ -1,6 +1,4 @@ @@ -128,7 +88,7 @@ const superform = superForm(defaults(zod(createRuleSchema)), { - +
@@ -139,7 +99,7 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- + Display Name @@ -157,14 +118,15 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- + Description Enter the description @@ -172,31 +134,31 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- + Tags - + Enter the tags
- + Annotations @@ -205,7 +167,7 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- + Source Enter the source @@ -220,7 +183,7 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- + Source port Enter the source port @@ -235,7 +199,7 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- + Destination Enter the destination @@ -250,7 +215,7 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- + Destination port @@ -266,13 +232,13 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- + Protocols Enter Weight @@ -344,7 +322,7 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- + App id If no app is selected, throttle rate applied system wide. @@ -359,10 +338,11 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- +
Bandwidth limit -
+
{$formData.throttleRate} /100
@@ -379,35 +359,37 @@ const superform = superForm(defaults(zod(createRuleSchema)), {
- + - Active + Active {$formData.active ? 'On' : 'Off'}
-
- -
-
- -
-
- - - -
- +
@@ -416,5 +398,22 @@ const superform = superForm(defaults(zod(createRuleSchema)), { + + + diff --git a/apps/console/src/routes/(app)/testrule/+page.gql b/apps/console/src/routes/(app)/testrule/+page.gql new file mode 100644 index 00000000..6df33a78 --- /dev/null +++ b/apps/console/src/routes/(app)/testrule/+page.gql @@ -0,0 +1,15 @@ +# query MyQuery { +# rules { +# id +# displayName +# } +# } + +query MyQuery { + test_rule { + a + b + c + d + } +} diff --git a/apps/console/src/routes/(app)/testrule/+page.svelte b/apps/console/src/routes/(app)/testrule/+page.svelte new file mode 100644 index 00000000..43cb4fcc --- /dev/null +++ b/apps/console/src/routes/(app)/testrule/+page.svelte @@ -0,0 +1,14 @@ + +{#if $MyQuery.fetching} +loading... +{:else} +
+      {JSON.stringify($MyQuery.data,null,2) }
+    
+{/if} diff --git a/nhost/metadata/databases/default/tables/public_test_rule.yaml b/nhost/metadata/databases/default/tables/public_test_rule.yaml new file mode 100644 index 00000000..2f680ff8 --- /dev/null +++ b/nhost/metadata/databases/default/tables/public_test_rule.yaml @@ -0,0 +1,13 @@ +table: + name: test_rule + schema: public +select_permissions: + - role: user + permission: + columns: + - c + - d + - b + - a + filter: {} + comment: "" diff --git a/nhost/metadata/databases/default/tables/tables.yaml b/nhost/metadata/databases/default/tables/tables.yaml index 2456c0e0..3cfb9da4 100644 --- a/nhost/metadata/databases/default/tables/tables.yaml +++ b/nhost/metadata/databases/default/tables/tables.yaml @@ -21,6 +21,7 @@ - "!include public_protocol.yaml" - "!include public_rules.yaml" - "!include public_subject_type.yaml" +- "!include public_test_rule.yaml" - "!include public_user_groups.yaml" - "!include public_user_org_roles.yaml" - "!include storage_buckets.yaml" diff --git a/nhost/migrations/default/1724523120859_create_table_public_test_rule/down.sql b/nhost/migrations/default/1724523120859_create_table_public_test_rule/down.sql new file mode 100644 index 00000000..7e948d68 --- /dev/null +++ b/nhost/migrations/default/1724523120859_create_table_public_test_rule/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."test_rule"; diff --git a/nhost/migrations/default/1724523120859_create_table_public_test_rule/up.sql b/nhost/migrations/default/1724523120859_create_table_public_test_rule/up.sql new file mode 100644 index 00000000..da178780 --- /dev/null +++ b/nhost/migrations/default/1724523120859_create_table_public_test_rule/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."test_rule" ("a" uuid NOT NULL, "b" timestamptz NOT NULL, "c" boolean NOT NULL, "d" integer NOT NULL, PRIMARY KEY ("a") );COMMENT ON TABLE "public"."test_rule" IS E'created by nithin, just for testing'; diff --git a/nhost/migrations/default/1724523307242_alter_table_public_test_rule_alter_column_b/down.sql b/nhost/migrations/default/1724523307242_alter_table_public_test_rule_alter_column_b/down.sql new file mode 100644 index 00000000..02388ef1 --- /dev/null +++ b/nhost/migrations/default/1724523307242_alter_table_public_test_rule_alter_column_b/down.sql @@ -0,0 +1 @@ +ALTER TABLE "public"."test_rule" ALTER COLUMN "b" drop default; diff --git a/nhost/migrations/default/1724523307242_alter_table_public_test_rule_alter_column_b/up.sql b/nhost/migrations/default/1724523307242_alter_table_public_test_rule_alter_column_b/up.sql new file mode 100644 index 00000000..1474b660 --- /dev/null +++ b/nhost/migrations/default/1724523307242_alter_table_public_test_rule_alter_column_b/up.sql @@ -0,0 +1 @@ +alter table "public"."test_rule" alter column "b" set default now(); diff --git a/nhost/migrations/default/1724523315190_alter_table_public_test_rule_alter_column_a/down.sql b/nhost/migrations/default/1724523315190_alter_table_public_test_rule_alter_column_a/down.sql new file mode 100644 index 00000000..fddde79e --- /dev/null +++ b/nhost/migrations/default/1724523315190_alter_table_public_test_rule_alter_column_a/down.sql @@ -0,0 +1 @@ +ALTER TABLE "public"."test_rule" ALTER COLUMN "a" drop default; diff --git a/nhost/migrations/default/1724523315190_alter_table_public_test_rule_alter_column_a/up.sql b/nhost/migrations/default/1724523315190_alter_table_public_test_rule_alter_column_a/up.sql new file mode 100644 index 00000000..df2343fe --- /dev/null +++ b/nhost/migrations/default/1724523315190_alter_table_public_test_rule_alter_column_a/up.sql @@ -0,0 +1 @@ +alter table "public"."test_rule" alter column "a" set default gen_random_uuid();