Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.

Commit

Permalink
refactor: reorganize to unify multiple SQL notebook types
Browse files Browse the repository at this point in the history
  • Loading branch information
shah committed Aug 25, 2024
1 parent 5070483 commit 8581622
Show file tree
Hide file tree
Showing 25 changed files with 3,305 additions and 172 deletions.
2 changes: 1 addition & 1 deletion pattern/digital-health/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// remote: https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.4

export * from "../../prime/deps.ts";
export * as SqlPageNotebook from "../../prime/sqlpage-notebook.ts";
export { sqlPageNB } from "../../prime/notebook/mod.ts";
9 changes: 4 additions & 5 deletions pattern/digital-health/ux.sql.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --allow-run --allow-sys
import { SqlPageNotebook as spn } from "./deps.ts";
import { sqlPageNB as spn } from "./deps.ts";
import {
console as c,
orchestration as orch,
shell as sh,
uniformResource as ur,
} from "../../prime/content/mod.ts";
import { TypicalSqlPageNotebook } from "../../prime/sqlpage-notebook.ts";
} from "../../prime/web-ui-content/mod.ts";

// custom decorator that makes navigation for this notebook type-safe
function fhirNav(route: Omit<spn.RouteConfig, "path" | "parentPath">) {
Expand Down Expand Up @@ -172,10 +171,10 @@ export class FhirSqlPages extends spn.TypicalSqlPageNotebook {
// this will be used by any callers who want to serve it as a CLI with SDTOUT
if (import.meta.main) {
const SQL = await spn.TypicalSqlPageNotebook.SQL(
new class extends TypicalSqlPageNotebook {
new class extends spn.TypicalSqlPageNotebook {
async statelessFhirSQL() {
// read the file from either local or remote (depending on location of this file)
return await TypicalSqlPageNotebook.fetchText(
return await spn.TypicalSqlPageNotebook.fetchText(
import.meta.resolve("./stateless-fhir.surveilr.sql"),
);
}
Expand Down
2 changes: 1 addition & 1 deletion pattern/direct-messaging-service/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// remote: https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.4

export * from "../../prime/deps.ts";
export * as SqlPageNotebook from "../../prime/sqlpage-notebook.ts";
export { sqlPageNB } from "../../prime/notebook/mod.ts";
4 changes: 2 additions & 2 deletions pattern/direct-messaging-service/ux.sql.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --allow-run --allow-sys
import { SqlPageNotebook as spn } from "./deps.ts";
import { sqlPageNB as spn } from "./deps.ts";
import {
console as c,
orchestration as orch,
shell as sh,
uniformResource as ur,
} from "../../prime/content/mod.ts";
} from "../../prime/web-ui-content/mod.ts";

// custom decorator that makes navigation for this notebook type-safe
function dmsNav(route: Omit<spn.RouteConfig, "path" | "parentPath">) {
Expand Down
2 changes: 1 addition & 1 deletion pattern/infra-policies/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
// remote: https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.4

export * from "../../prime/deps.ts";
export * as SqlPageNotebook from "../../prime/sqlpage-notebook.ts";
export { sqlPageNB } from "../../prime/notebook/mod.ts";
4 changes: 2 additions & 2 deletions pattern/infra-policies/ux.sql.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --allow-run --allow-sys
import { SqlPageNotebook as spn } from "./deps.ts";
import { sqlPageNB as spn } from "./deps.ts";
import {
console as c,
orchestration as orch,
shell as sh,
uniformResource as ur,
} from "../../prime/content/mod.ts";
} from "../../prime/web-ui-content/mod.ts";

// custom decorator that makes navigation for this notebook type-safe
function ipNav(route: Omit<spn.RouteConfig, "path" | "parentPath">) {
Expand Down
12 changes: 7 additions & 5 deletions prime/deps.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// local: ../../../netspective-labs/sql-aide
// remote: https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.7
// remote: https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.8

export * as path from "https://deno.land/[email protected]/path/mod.ts";
export * as ws from "https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.7/lib/universal/whitespace.ts";
export * as SQLa from "https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.7/render/mod.ts";
export * as SQLa_typ from "https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.7/pattern/typical/mod.ts";
export * as callable from "https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.7/lib/reflect/callable.ts";
export * as ulid from "https://deno.land/[email protected]/ulid/mod.ts";
export * as ws from "https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.8/lib/universal/whitespace.ts";
export * as user from "https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.8/lib/universal/os-user.ts";
export * as SQLa from "https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.8/render/mod.ts";
export * as SQLa_typ from "https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.8/pattern/typical/mod.ts";
export * as callable from "https://raw.githubusercontent.com/netspective-labs/sql-aide/v0.14.8/lib/reflect/callable.ts";
63 changes: 63 additions & 0 deletions prime/lifecycle.sql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env -S deno run --allow-read --allow-write --allow-env --allow-run --allow-sys
import { cell, TypicalCodeNotebook } from "./notebook/code.ts";
import { lifecycle as lcm } from "./models/mod.ts";

export class BootstrapNotebook extends TypicalCodeNotebook {
readonly codeNbModels = lcm.codeNotebooksModels();
readonly serviceModels = lcm.serviceModels();

constructor() {
super("bootstrap", {
code_notebook_kernel_id: "SQL",
kernel_name: "SQLite SQL Statements",
mime_type: "application/sql",
file_extn: ".sql",
});
}

bootstrapDDL() {
return this.SQL`
${this.codeNbModels.informationSchema.tables}
${this.codeNbModels.informationSchema.tableIndexes}
`;
}

bootstrapSeedDML() {
return [
this.kernelUpsertStmt({
code_notebook_kernel_id: "SQL",
kernel_name: "SQLite SQL Statements",
mime_type: "application/sql",
file_extn: ".sql",
}),
this.kernelUpsertStmt({
code_notebook_kernel_id: "DenoTaskShell",
kernel_name: "Deno Task Shell",
mime_type: "application/x-deno-task-sh",
file_extn: ".deno-task-sh",
}),
];
}

// note `once_` pragma means it must only be run once in the database; this
// `once_` pragma does not mean anything to the code_notebook_* infra but the
// naming convention does tell `surveilr` migration lifecycle how to operate
// the cell at runtime initiatlize of the RSSD.
@cell()
v001_once_initialDDL() {
// deno-fmt-ignore
return this.SQL`
-- ${this.tsProvenanceComment(import.meta.url)}
${this.serviceModels.informationSchema.tables}
${this.serviceModels.informationSchema.tableIndexes}`;
}
}

// this will be used by any callers who want to serve it as a CLI with SDTOUT
if (import.meta.main) {
const SQL = await TypicalCodeNotebook.SQL(new BootstrapNotebook());
console.log(SQL.join("\n"));
}
Loading

1 comment on commit 8581622

@deno-deploy
Copy link

@deno-deploy deno-deploy bot commented on 8581622 Aug 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed to deploy:

Your deployment uses decorators. The default for 'experimentalDecorators' will be changing to 'false'. In the meantime, please explicitly set the 'experimentalDecorators' compiler option. For more information, see https://deno.com/deploy/changelog#es-decorators-are-enabled-on-deno-deploy-replacing-experimental-ts-decorators

Please sign in to comment.