Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dbpath/pathparser

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dbpath/pathparser - npm Package Compare versions

Comparing version 0.2.19 to 0.2.20

6

dist/src/parser.d.ts

@@ -5,3 +5,4 @@ import { Token } from "./tokeniser";

import { LinkInPath, PathItem, TableInPath, TwoIds } from "@dbpath/types";
export interface TableAndFullTableName {
export interface SchemaAndTable {
schema?: string;
table: string;

@@ -27,3 +28,4 @@ fullTable?: string;

export declare const parseIdEqualsId: (c: ParserContext) => ResultAndContext<TwoIds>;
export declare function parseTableName(context: ParserContext): ResultAndContext<TableAndFullTableName>;
export declare const parseSchemaAndTable: (context: ParserContext) => ResultAndContext<SchemaAndTable>;
export declare function parseSchemaAndTableNameAdjustingForSummary(context: ParserContext): ResultAndContext<SchemaAndTable>;
export declare const parseTable: (context: ParserContext) => ResultAndContext<TableInPath>;

@@ -30,0 +32,0 @@ export declare const parseTableAndNextLink: (previousLink: TableInPath | undefined, idEquals: TwoIds[]) => PathParser<LinkInPath>;

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.errorData = exports.parsePath = exports.parseTableAndLinks = exports.parseLink = exports.parseTableAndNextLink = exports.parseTable = exports.parseTableName = exports.parseIdEqualsId = exports.parseBracketedCommaSeparated = exports.parseCommaSeparated = exports.gotForError = exports.identifier = void 0;
exports.errorData = exports.parsePath = exports.parseTableAndLinks = exports.parseLink = exports.parseTableAndNextLink = exports.parseTable = exports.parseSchemaAndTableNameAdjustingForSummary = exports.parseSchemaAndTable = exports.parseIdEqualsId = exports.parseBracketedCommaSeparated = exports.parseCommaSeparated = exports.gotForError = exports.identifier = void 0;
const tokeniser_1 = require("./tokeniser");

@@ -90,10 +90,22 @@ const utils_1 = require("@dbpath/utils");

exports.parseIdEqualsId = parseIdEqualsId;
function parseTableName(context) {
return mapParser((0, exports.identifier)('table name')(context), (c, tableName) => {
const table = context.validator.actualTableName(tableName);
return validateAndReturn(context, c, { table }, c.validator.validateTableName(table));
const parseSchemaAndTable = (context) => {
return mapParser((0, exports.identifier)('schema or table')(context), (c, schemaOrTable) => {
if (isNextChar(c, ":")) {
return mapParser(nextChar(c, ':'), c => mapParser((0, exports.identifier)('tableName')(c), (c, table) => {
let result = { schema: schemaOrTable, table };
return lift(c, result);
}));
}
return lift(c, { table: schemaOrTable });
});
};
exports.parseSchemaAndTable = parseSchemaAndTable;
function parseSchemaAndTableNameAdjustingForSummary(context) {
return mapParser((0, exports.parseSchemaAndTable)(context), (c, schemaAndTable) => {
const table = context.validator.actualTableName(schemaAndTable.table);
return validateAndReturn(context, c, Object.assign(Object.assign({}, schemaAndTable), { table }), c.validator.validateTableName(table));
});
}
exports.parseTableName = parseTableName;
const parseTable = (context) => mapParser(parseTableName(context), (cEndOfTable, tableName) => mapParser(parseBracketedCommaSeparated(cEndOfTable, '[', ',', (0, exports.identifier)('field'), ']'), (c, fields) => validateAndReturn(cEndOfTable, c, Object.assign(Object.assign({}, tableName), { fields, pk: c.validator.pkFor(tableName.table) }), c.validator.validateFields(tableName.table, fields))));
exports.parseSchemaAndTableNameAdjustingForSummary = parseSchemaAndTableNameAdjustingForSummary;
const parseTable = (context) => mapParser(parseSchemaAndTableNameAdjustingForSummary(context), (cEndOfTable, tableName) => mapParser(parseBracketedCommaSeparated(cEndOfTable, '[', ',', (0, exports.identifier)('field'), ']'), (c, fields) => validateAndReturn(cEndOfTable, c, Object.assign(Object.assign({}, tableName), { fields, pk: c.validator.pkFor(tableName.table) }), c.validator.validateFields(tableName.table, fields))));
exports.parseTable = parseTable;

@@ -100,0 +112,0 @@ const parseTableAndNextLink = (previousLink, idEquals) => context => mapParser((0, exports.parseTable)(context), (c, table) => {

@@ -124,3 +124,3 @@ "use strict";

});
it("should parse .drive!fullDrive[f1,f2].(id1=id2)mission[f3].(id3=id4)audit", () => {
it("should parse .drive[f1,f2].(id1=id2)mission[f3].audit", () => {
expect(pl(".driver[f1,f2].mission.audit", 11)).toEqual({

@@ -191,3 +191,3 @@ "previousLink": {

" ^",
"Expected a table name unexpected character ["
"Expected a schema or table unexpected character ["
]);

@@ -205,2 +205,37 @@ });

});
describe("schemas", () => {
it("should process s0:driver.(driverId=id)s1:mission.s2:audit", () => {
expect((0, parser_1.parsePath)(validator)(" s0:driver.(driverId=id)s1:mission.s2:audit")).toEqual({
"fields": [],
"idEquals": [],
"pk": [
"id"
],
"previousLink": {
"fields": [],
"idEquals": [
{
"fromId": "driverId",
"toId": "id"
}
],
"pk": [
"id"
],
"previousLink": {
"fields": [],
"pk": [
"driverId"
],
"schema": " s0",
"table": "drivertable"
},
"schema": "s1",
"table": "mission"
},
"schema": "s2",
"table": "driver_aud"
});
});
});
describe("PathValidator in parsePath", () => {

@@ -207,0 +242,0 @@ it("should be called", () => {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tokenise = exports.tokeniseNext = void 0;
const specials = "[](),.=";
const specials = "[](),.=:";
function tokeniseNext(context) {

@@ -6,0 +6,0 @@ const initialPos = context.pos;

{
"name": "@dbpath/pathparser",
"description": "",
"version": "0.2.19",
"version": "0.2.20",
"main": "dist/index",

@@ -20,5 +20,5 @@ "types": "dist/index",

"dependencies": {
"@dbpath/types": "0.2.19",
"@dbpath/utils": "0.2.19",
"@dbpath/fixtures": "0.2.19"
"@dbpath/types": "0.2.20",
"@dbpath/utils": "0.2.20",
"@dbpath/fixtures": "0.2.20"
},

@@ -25,0 +25,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc