Security News
Fluent Assertions Faces Backlash After Abandoning Open Source Licensing
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
@latitude-data/sql-compiler
Advanced tools
import { emptyMetadata, readMetadata } from '..' import CompileError from '../error/error' import { describe, it, expect, beforeEach, vi } from 'vitest'
describe('config tags', async () => {
it('extracts defined configurations correctly', async () => {
const query = {@config foo = 5} {@config bar = "foo"} {@config baz = true} Rest of the query
const { config } = await readMetadata({ query })
expect(config).toEqual({
foo: 5,
bar: 'foo',
baz: true,
})
})
it('fails when a config tag is not at root level', async () => {
const query = {#if true} {@config foo = 5} {/if}
try {
await readMetadata({ query })
} catch (e) {
expect(e).toBeInstanceOf(CompileError)
expect((e as CompileError).code).toBe('config-inside-block')
}
})
it('fails when a config tag is not a valid assignment expression', async () => {
const query = {@config foo 5}
try {
await readMetadata({ query })
} catch (e) {
expect(e).toBeInstanceOf(CompileError)
expect((e as CompileError).code).toBe('invalid-config-args')
}
})
it('fails when a config value is not a literal', async () => {
const query = {@config foo = 5 + 5}
try {
await readMetadata({ query })
} catch (e) {
expect(e).toBeInstanceOf(CompileError)
expect((e as CompileError).code).toBe('invalid-config-value')
}
})
it('fails when a config is already defined', async () => {
const query = {@config foo = 5} {@config foo = 10}
try {
await readMetadata({ query })
} catch (e) {
expect(e).toBeInstanceOf(CompileError)
expect((e as CompileError).code).toBe('config-already-defined')
}
})
})
describe('supported methods', async () => { function mockSupportedMethod() { return { requirements: {}, resolve: vi.fn(() => Promise.resolve()), readMetadata: vi.fn(() => Promise.resolve(emptyMetadata())), } }
beforeEach(() => { vi.clearAllMocks() })
it('extracts supported methods present in the query correctly', async () => {
const query = {foo()} {bar()} {baz()}
const supportedMethods = {
foo: mockSupportedMethod(),
bar: mockSupportedMethod(),
}
const { methods } = await readMetadata({ query, supportedMethods })
expect(methods).toContain('foo')
expect(methods).toContain('bar')
})
it('does not extract method calls that are not from supported methods', async () => {
const query = {foo()} {bar()} {baz()}
const supportedMethods = {
foo: mockSupportedMethod(),
}
const { methods } = await readMetadata({ query, supportedMethods })
expect(methods).toContain('foo')
expect(methods).not.toContain('bar')
expect(methods).not.toContain('baz')
})
it('does not extract supported methods that are not present in the query', async () => {
const query = {foo()}
const supportedMethods = {
foo: mockSupportedMethod(),
bar: mockSupportedMethod(),
}
const { methods } = await readMetadata({ query, supportedMethods })
expect(methods).toContain('foo')
expect(methods).not.toContain('bar')
})
it('does not actually run extracted methods', async () => {
const query = {foo()}
const supportedMethods = {
foo: mockSupportedMethod(),
bar: mockSupportedMethod(),
}
const { methods } = await readMetadata({ query, supportedMethods })
expect(methods).toContain('foo')
expect(supportedMethods.foo.resolve).not.toHaveBeenCalled()
}) })
FAQs
Compiler for Latitude's custom sql sintax based on svelte
The npm package @latitude-data/sql-compiler receives a total of 13 weekly downloads. As such, @latitude-data/sql-compiler popularity was classified as not popular.
We found that @latitude-data/sql-compiler demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.
Research
Security News
Socket researchers uncover the risks of a malicious Python package targeting Discord developers.
Security News
The UK is proposing a bold ban on ransomware payments by public entities to disrupt cybercrime, protect critical services, and lead global cybersecurity efforts.