@dataform/core
Advanced tools
Comparing version 0.0.2-alpha.33 to 0.0.2-alpha.34
import * as protos from "@dataform/protos"; | ||
import { Dataform } from "./index"; | ||
import { Session } from "./index"; | ||
export declare type AContextable<T> = T | ((ctx: AssertionContext) => T); | ||
export declare class Assertion { | ||
proto: protos.IAssertion; | ||
dataform: Dataform; | ||
session: Session; | ||
private contextableQuery; | ||
@@ -8,0 +8,0 @@ query(query: AContextable<string>): this; |
@@ -36,3 +36,3 @@ "use strict"; | ||
this.assertion.dependencies(name); | ||
return this.assertion.dataform.ref(name); | ||
return this.assertion.session.ref(name); | ||
} | ||
@@ -39,0 +39,0 @@ dependencies(name) { |
import * as protos from "@dataform/protos"; | ||
import { Dataform } from "./dataform"; | ||
import { Session } from "./session"; | ||
import { Materialization, MaterializationContext, MConfig } from "./materialization"; | ||
@@ -8,9 +8,10 @@ import { Operation, OContextable } from "./operation"; | ||
import * as utils from "./utils"; | ||
import * as compilers from "./compilers"; | ||
import * as tasks from "./tasks"; | ||
export { adapters, utils, tasks, Dataform, Materialization, MaterializationContext, MConfig, Operation, Assertion }; | ||
export declare const singleton: Dataform; | ||
export declare const materialize: (name: string, queryOrConfig?: string | MConfig | ((ctx: MaterializationContext) => string)) => Materialization; | ||
export declare const operate: (name: string, statement?: OContextable<string | string[]>) => Operation; | ||
export declare const assert: (name: string, query?: AContextable<string>) => Assertion; | ||
export declare const compile: () => protos.ICompiledGraph; | ||
export declare const init: (projectConfig?: protos.IProjectConfig) => void; | ||
export { adapters, utils, compilers, tasks, Session, Materialization, MaterializationContext, MConfig, Operation, Assertion }; | ||
export declare const session: any; | ||
export declare const materialize: (name: string, queryOrConfig?: string | MConfig | ((ctx: MaterializationContext) => string)) => any; | ||
export declare const operate: (name: string, statement?: OContextable<string | string[]>) => any; | ||
export declare const assert: (name: string, query?: AContextable<string>) => any; | ||
export declare const compile: () => any; | ||
export declare const init: (rootDir: string, projectConfig?: protos.IProjectConfig) => any; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const dataform_1 = require("./dataform"); | ||
exports.Dataform = dataform_1.Dataform; | ||
const session_1 = require("./session"); | ||
exports.Session = session_1.Session; | ||
const materialization_1 = require("./materialization"); | ||
@@ -16,2 +16,4 @@ exports.Materialization = materialization_1.Materialization; | ||
exports.utils = utils; | ||
const compilers = require("./compilers"); | ||
exports.compilers = compilers; | ||
const tasks = require("./tasks"); | ||
@@ -24,12 +26,3 @@ exports.tasks = tasks; | ||
module._compile = oldCompile; | ||
var transformedCode; | ||
if (file.endsWith(".assert.sql")) { | ||
transformedCode = utils.compileAssertionSql(code, file); | ||
} | ||
else if (file.endsWith(".ops.sql")) { | ||
transformedCode = utils.compileOperationSql(code, file); | ||
} | ||
else { | ||
transformedCode = utils.compileMaterializationSql(code, file); | ||
} | ||
var transformedCode = compilers.compile(code, file); | ||
module._compile(transformedCode, file); | ||
@@ -40,8 +33,11 @@ }; | ||
} | ||
exports.singleton = new dataform_1.Dataform(); | ||
exports.materialize = (name, queryOrConfig) => exports.singleton.materialize(name, queryOrConfig); | ||
exports.operate = (name, statement) => exports.singleton.operate(name, statement); | ||
exports.assert = (name, query) => exports.singleton.assert(name, query); | ||
exports.compile = () => exports.singleton.compile(); | ||
exports.init = (projectConfig) => exports.singleton.init(projectConfig); | ||
const existingGlobalSession = global._DF_SESSION; | ||
exports.session = existingGlobalSession || new session_1.Session(process.cwd()); | ||
global._DF_SESSION = exports.session; | ||
exports.materialize = (name, queryOrConfig) => exports.session.materialize(name, queryOrConfig); | ||
exports.operate = (name, statement) => exports.session.operate(name, statement); | ||
exports.assert = (name, query) => exports.session.assert(name, query); | ||
exports.compile = () => exports.session.compile(); | ||
exports.init = (rootDir, projectConfig) => exports.session.init(rootDir, projectConfig); | ||
global.session = exports.session; | ||
global.materialize = exports.materialize; | ||
@@ -48,0 +44,0 @@ global.operate = exports.operate; |
@@ -1,2 +0,2 @@ | ||
import { Dataform } from "./index"; | ||
import { Session } from "./index"; | ||
import * as protos from "@dataform/protos"; | ||
@@ -15,6 +15,7 @@ export declare type MContextable<T> = T | ((ctx: MaterializationContext) => T); | ||
}; | ||
disabled?: boolean; | ||
} | ||
export declare class Materialization { | ||
proto: protos.Materialization; | ||
dataform: Dataform; | ||
session: Session; | ||
private contextableQuery; | ||
@@ -30,2 +31,3 @@ private contextableWhere; | ||
postOps(posts: MContextable<string | string[]>): this; | ||
disabled(): this; | ||
dependencies(value: string | string[]): this; | ||
@@ -49,2 +51,3 @@ descriptor(key: string, description?: string): any; | ||
postOps(statement: MContextable<string | string[]>): string; | ||
disabled(): string; | ||
dependencies(name: string): string; | ||
@@ -51,0 +54,0 @@ descriptor(key: string, description?: string): any; |
@@ -7,3 +7,4 @@ "use strict"; | ||
this.proto = protos.Materialization.create({ | ||
type: "view" | ||
type: "view", | ||
disabled: false | ||
}); | ||
@@ -35,2 +36,5 @@ this.contextablePreOps = []; | ||
} | ||
if (config.disabled) { | ||
this.disabled(); | ||
} | ||
return this; | ||
@@ -58,2 +62,6 @@ } | ||
} | ||
disabled() { | ||
this.proto.disabled = true; | ||
return this; | ||
} | ||
dependencies(value) { | ||
@@ -118,7 +126,7 @@ var newDependencies = typeof value === "string" ? [value] : value; | ||
self() { | ||
return this.materialization.dataform.adapter().resolveTarget(this.materialization.proto.target); | ||
return this.materialization.session.adapter().resolveTarget(this.materialization.proto.target); | ||
} | ||
ref(name) { | ||
this.materialization.dependencies(name); | ||
return this.materialization.dataform.ref(name); | ||
return this.materialization.session.ref(name); | ||
} | ||
@@ -141,2 +149,6 @@ type(type) { | ||
} | ||
disabled() { | ||
this.materialization.disabled(); | ||
return ""; | ||
} | ||
dependencies(name) { | ||
@@ -143,0 +155,0 @@ this.materialization.dependencies(name); |
import * as protos from "@dataform/protos"; | ||
import { Dataform } from "./index"; | ||
import { Session } from "./index"; | ||
export declare type OContextable<T> = T | ((ctx: OperationContext) => T); | ||
export declare class Operation { | ||
proto: protos.IOperation; | ||
dataform: Dataform; | ||
session: Session; | ||
private contextableQueries; | ||
@@ -8,0 +8,0 @@ queries(queries: OContextable<string | string[]>): this; |
@@ -36,3 +36,3 @@ "use strict"; | ||
this.operation.dependencies(name); | ||
return this.operation.dataform.ref(name); | ||
return this.operation.session.ref(name); | ||
} | ||
@@ -39,0 +39,0 @@ dependencies(name) { |
export declare function relativePath(path: string, base: string): string; | ||
export declare function baseFilename(path: string): string; | ||
export declare function compileMaterializationSql(code: string, path: string): string; | ||
export declare function compileOperationSql(code: string, path: string): string; | ||
export declare function compileAssertionSql(code: string, path: string): string; | ||
export declare function variableNameFriendly(value: string): string; | ||
export declare function matchPatterns(patterns: string[], values: string[]): string[]; | ||
export declare function getCallerFile(rootDir: string): string; |
@@ -21,37 +21,2 @@ "use strict"; | ||
exports.baseFilename = baseFilename; | ||
function compileMaterializationSql(code, path) { | ||
return ` | ||
materialize("${baseFilename(path)}").query(ctx => { | ||
const config = ctx.config.bind(ctx); | ||
const type = ctx.type.bind(ctx); | ||
const preOps = ctx.preOps.bind(ctx); | ||
const postOps = ctx.postOps.bind(ctx); | ||
const ref = ctx.ref.bind(ctx); | ||
const self = ctx.self.bind(ctx); | ||
const dependencies = ctx.dependencies.bind(ctx); | ||
const where = ctx.where.bind(ctx); | ||
const descriptor = ctx.descriptor.bind(ctx); | ||
const describe = ctx.describe.bind(ctx); | ||
return \`${code}\`; | ||
})`; | ||
} | ||
exports.compileMaterializationSql = compileMaterializationSql; | ||
function compileOperationSql(code, path) { | ||
return ` | ||
operate("${baseFilename(path)}").queries(ctx => { | ||
const ref = ctx.ref.bind(ctx); | ||
const dependencies = ctx.dependencies.bind(ctx); | ||
return \`${code}\`.split("\\n---\\n"); | ||
})`; | ||
} | ||
exports.compileOperationSql = compileOperationSql; | ||
function compileAssertionSql(code, path) { | ||
return ` | ||
assert("${baseFilename(path)}").query(ctx => { | ||
const ref = ctx.ref.bind(ctx); | ||
const dependencies = ctx.dependencies.bind(ctx); | ||
return \`${code}\`; | ||
})`; | ||
} | ||
exports.compileAssertionSql = compileAssertionSql; | ||
function variableNameFriendly(value) { | ||
@@ -58,0 +23,0 @@ return value |
{ | ||
"name": "@dataform/core", | ||
"version": "0.0.2-alpha.33", | ||
"version": "0.0.2-alpha.34", | ||
"description": "Dataform core API.", | ||
@@ -8,3 +8,3 @@ "main": "build/index.js", | ||
"dependencies": { | ||
"@dataform/protos": "^0.0.2-alpha.33", | ||
"@dataform/protos": "^0.0.2-alpha.34", | ||
"protobufjs": "^6.8.8" | ||
@@ -15,3 +15,3 @@ }, | ||
}, | ||
"gitHead": "ddce1d798aa2672b3545f4ac07152c09fe3e0a2c" | ||
"gitHead": "641b6e6810b80d24a9162f1c109cd73c045e7754" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
206250
40
4239