semanticdb-v2 2.0.0-alpha.7 → 2.0.0-alpha.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -9
- package/dist/cache/index.d.ts +2 -1
- package/dist/cache/manager.d.ts +5 -0
- package/dist/cache/registry.d.ts +14 -0
- package/dist/cache/types.d.ts +15 -0
- package/dist/close.d.ts +1 -0
- package/dist/executor/execute-query.d.ts +3 -2
- package/dist/executor/federated-execution.d.ts +2 -1
- package/dist/executor/fetch-entities.d.ts +2 -1
- package/dist/executor/index.d.ts +1 -1
- package/dist/executor/types.d.ts +11 -4
- package/dist/index.d.ts +5 -7
- package/dist/logicform-types.d.ts +1 -12
- package/dist/operators/index.d.ts +1 -1
- package/dist/operators/registry.d.ts +4 -2
- package/dist/operators/types.d.ts +25 -16
- package/dist/planner/semantics/registry.d.ts +2 -1
- package/dist/plugins/observation/operator-policy.d.ts +2 -2
- package/dist/semantic-types/types.d.ts +3 -0
- package/dist/semanticdb.esm.js +5 -5
- package/dist/semanticdb.js +5 -5
- package/package.json +1 -1
- package/dist/cache/redis-query-cache.esm.js +0 -1
- package/dist/cache/redis-query-cache.js +0 -1
- package/dist/calendar/constants.d.ts +0 -7
- package/dist/calendar/index.d.ts +0 -6
- package/dist/calendar/provider-relation-store.d.ts +0 -9
- package/dist/calendar/resolver.d.ts +0 -10
- package/dist/calendar/system-schemas.d.ts +0 -3
- package/dist/calendar/types.d.ts +0 -31
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{createClient as b}from"redis";import{createHash as g}from"node:crypto";const o=e=>e===void 0?{type:"undefined"}:typeof e=="bigint"?{type:"bigint",value:e.toString()}:typeof e=="number"&&!Number.isFinite(e)?{type:"number",value:String(e)}:e instanceof Date?{type:"date",value:e.toISOString()}:Array.isArray(e)?e.map(o):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>[t,o(r)])):e,d=e=>g("sha256").update(JSON.stringify(o(e))).digest("hex"),A=e=>d({namespace:e.namespace,provider:e.provider,connectionId:e.connectionId,sql:e.sql,parameters:e.parameters}),S=(e,t)=>d({namespace:e,source:t}),a=e=>e===void 0?{type:"undefined"}:typeof e=="bigint"?{type:"bigint",value:e.toString()}:typeof e=="number"&&!Number.isFinite(e)?{type:"number",value:String(e)}:e instanceof Date?{type:"date",value:e.toISOString()}:Array.isArray(e)?{type:"array",value:e.map(a)}:e&&typeof e=="object"?{type:"object",value:Object.entries(e).map(([t,r])=>[t,a(r)])}:e,f=e=>{if(e===null||typeof e!="object")return e;switch(e.type){case"undefined":return;case"bigint":return BigInt(e.value);case"number":return Number(e.value);case"date":return new Date(e.value);case"array":return e.value.map(f);case"object":return Object.fromEntries(e.value.map(([t,r])=>[t,f(r)]))}},w=e=>JSON.stringify(a(e)),x=e=>{const t=f(JSON.parse(e));if(!(!Array.isArray(t)||t.some(r=>!r||typeof r!="object"||Array.isArray(r))))return t},l=Number.MAX_SAFE_INTEGER;class p{#e;#t;#r;constructor(t,r={}){this.#e=t,this.#t=r.keyPrefix??"semanticdb:cache",this.#r=r.ownsClient??!1}#n(t){return`${this.#t}:query:${A(t)}`}#i(t,r){return`${this.#t}:source:${S(t,r)}`}async get(t){const r=await this.#e.get(this.#n(t));if(r!==null)return x(r)}async set(t,r,i){const n=this.#n(t),y=w(r),c=i.expiresAt?.getTime(),m=c??l,s=this.#e.multi();c===void 0?s.set(n,y):s.set(n,y,{PXAT:c});for(const h of new Set(i.sources)){const u=this.#i(t.namespace,h);s.zRemRangeByScore(u,0,Date.now()),s.zAdd(u,{score:m,value:n})}await s.exec()}async invalidateSource(t,r){const i=this.#i(t,r),n=await this.#e.zRange(i,0,-1);n.length>0&&await this.#e.del(n),await this.#e.del(i)}async close(){this.#r&&await this.#e.close()}}const j=async(e={})=>{const t=b(e.url?{url:e.url}:{});return t.on("error",()=>{}),await t.connect(),new p(t,{...e.keyPrefix?{keyPrefix:e.keyPrefix}:{},ownsClient:!0})};export{p as RedisQueryCache,j as createRedisQueryCache};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var b=require("redis"),g=require("node:crypto");const a=e=>e===void 0?{type:"undefined"}:typeof e=="bigint"?{type:"bigint",value:e.toString()}:typeof e=="number"&&!Number.isFinite(e)?{type:"number",value:String(e)}:e instanceof Date?{type:"date",value:e.toISOString()}:Array.isArray(e)?e.map(a):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>[t,a(r)])):e,d=e=>g.createHash("sha256").update(JSON.stringify(a(e))).digest("hex"),A=e=>d({namespace:e.namespace,provider:e.provider,connectionId:e.connectionId,sql:e.sql,parameters:e.parameters}),S=(e,t)=>d({namespace:e,source:t}),o=e=>e===void 0?{type:"undefined"}:typeof e=="bigint"?{type:"bigint",value:e.toString()}:typeof e=="number"&&!Number.isFinite(e)?{type:"number",value:String(e)}:e instanceof Date?{type:"date",value:e.toISOString()}:Array.isArray(e)?{type:"array",value:e.map(o)}:e&&typeof e=="object"?{type:"object",value:Object.entries(e).map(([t,r])=>[t,o(r)])}:e,u=e=>{if(e===null||typeof e!="object")return e;switch(e.type){case"undefined":return;case"bigint":return BigInt(e.value);case"number":return Number(e.value);case"date":return new Date(e.value);case"array":return e.value.map(u);case"object":return Object.fromEntries(e.value.map(([t,r])=>[t,u(r)]))}},w=e=>JSON.stringify(o(e)),x=e=>{const t=u(JSON.parse(e));if(!(!Array.isArray(t)||t.some(r=>!r||typeof r!="object"||Array.isArray(r))))return t},l=Number.MAX_SAFE_INTEGER;class p{#e;#t;#r;constructor(t,r={}){this.#e=t,this.#t=r.keyPrefix??"semanticdb:cache",this.#r=r.ownsClient??!1}#n(t){return`${this.#t}:query:${A(t)}`}#i(t,r){return`${this.#t}:source:${S(t,r)}`}async get(t){const r=await this.#e.get(this.#n(t));if(r!==null)return x(r)}async set(t,r,i){const n=this.#n(t),y=w(r),c=i.expiresAt?.getTime(),h=c??l,s=this.#e.multi();c===void 0?s.set(n,y):s.set(n,y,{PXAT:c});for(const m of new Set(i.sources)){const f=this.#i(t.namespace,m);s.zRemRangeByScore(f,0,Date.now()),s.zAdd(f,{score:h,value:n})}await s.exec()}async invalidateSource(t,r){const i=this.#i(t,r),n=await this.#e.zRange(i,0,-1);n.length>0&&await this.#e.del(n),await this.#e.del(i)}async close(){this.#r&&await this.#e.close()}}const C=async(e={})=>{const t=b.createClient(e.url?{url:e.url}:{});return t.on("error",()=>{}),await t.connect(),new p(t,{...e.keyPrefix?{keyPrefix:e.keyPrefix}:{},ownsClient:!0})};exports.RedisQueryCache=p,exports.createRedisQueryCache=C;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/** Fixed internal physical table names. These are intentionally not configurable yet. */
|
|
2
|
-
export declare const CALENDAR_DATES_TABLE = "semanticdb_calendar_dates";
|
|
3
|
-
export declare const CALENDAR_RELATIONS_TABLE = "semanticdb_calendar_relations";
|
|
4
|
-
export declare const CALENDAR_SYSTEM_SCHEMA_IDS: {
|
|
5
|
-
readonly dates: "__sdb_calendar_dates";
|
|
6
|
-
readonly relations: "__sdb_calendar_relations";
|
|
7
|
-
};
|
package/dist/calendar/index.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export { CALENDAR_DATES_TABLE, CALENDAR_RELATIONS_TABLE, CALENDAR_SYSTEM_SCHEMA_IDS, } from './constants';
|
|
2
|
-
export { resolveCalendarPeriod, resolveCalendarPeriodFromStore, selectCalendarDates, } from './resolver';
|
|
3
|
-
export type { CalendarRelationStore } from './resolver';
|
|
4
|
-
export { ProviderCalendarRelationStore } from './provider-relation-store';
|
|
5
|
-
export { calendarSystemSchemas } from './system-schemas';
|
|
6
|
-
export type { CalendarAlignment, CalendarComparison, CalendarDateRow, CalendarRelation, CalendarRelationRow, ResolvedCalendarPeriod, } from './types';
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { CoreComputeProvider } from '../physical/index';
|
|
2
|
-
import type { CalendarRelationStore } from './resolver';
|
|
3
|
-
import type { CalendarComparison, CalendarRelationRow } from './types';
|
|
4
|
-
/** Loads calendar mappings from the fixed internal relations table. */
|
|
5
|
-
export declare class ProviderCalendarRelationStore implements CalendarRelationStore {
|
|
6
|
-
private readonly provider;
|
|
7
|
-
constructor(provider: CoreComputeProvider);
|
|
8
|
-
loadRelations(currentDateIds: readonly (string | number)[], comparison: CalendarComparison): Promise<readonly CalendarRelationRow[]>;
|
|
9
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { CalendarComparison, CalendarDateRow, CalendarRelationRow, ResolvedCalendarPeriod } from './types';
|
|
2
|
-
export interface CalendarRelationStore {
|
|
3
|
-
loadRelations(currentDateIds: readonly (string | number)[], comparison: CalendarComparison): Promise<readonly CalendarRelationRow[]>;
|
|
4
|
-
}
|
|
5
|
-
/** Resolve current natural-day IDs through an explicit calendar relation. */
|
|
6
|
-
export declare const resolveCalendarPeriod: (currentDateIds: readonly (string | number)[], comparison: CalendarComparison, relations: readonly CalendarRelationRow[]) => ResolvedCalendarPeriod;
|
|
7
|
-
/** Async resolver boundary used by the executor; storage remains provider-owned. */
|
|
8
|
-
export declare const resolveCalendarPeriodFromStore: (currentDateIds: readonly (string | number)[], comparison: CalendarComparison, store: CalendarRelationStore) => Promise<ResolvedCalendarPeriod>;
|
|
9
|
-
/** Select natural days by calendar coordinates before resolving a relation. */
|
|
10
|
-
export declare const selectCalendarDates: (rows: readonly CalendarDateRow[], predicate: Partial<Pick<CalendarDateRow, "calendar" | "grain" | "periodKey" | "relativeDay">>) => readonly (string | number)[];
|
package/dist/calendar/types.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
export type CalendarRelation = 'previous_period' | 'next_period' | 'previous_occurrence' | 'next_occurrence';
|
|
2
|
-
export type CalendarAlignment = 'same_period' | 'same_elapsed_position' | 'same_relative_day';
|
|
3
|
-
export interface CalendarComparison {
|
|
4
|
-
readonly calendar: string;
|
|
5
|
-
readonly grain: string;
|
|
6
|
-
readonly relation: CalendarRelation;
|
|
7
|
-
readonly alignment?: CalendarAlignment;
|
|
8
|
-
readonly key?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface CalendarDateRow {
|
|
11
|
-
readonly dateId: string | number;
|
|
12
|
-
readonly calendar: string;
|
|
13
|
-
readonly grain: string;
|
|
14
|
-
readonly periodKey?: string | number;
|
|
15
|
-
readonly relativeDay?: number;
|
|
16
|
-
}
|
|
17
|
-
export interface CalendarRelationRow {
|
|
18
|
-
readonly sourceDateId: string | number;
|
|
19
|
-
readonly targetDateId: string | number | null;
|
|
20
|
-
readonly calendar: string;
|
|
21
|
-
readonly grain: string;
|
|
22
|
-
readonly relation: CalendarRelation;
|
|
23
|
-
readonly key?: string;
|
|
24
|
-
}
|
|
25
|
-
export interface ResolvedCalendarPeriod {
|
|
26
|
-
readonly dateIds: readonly (string | number)[];
|
|
27
|
-
readonly ranges: readonly {
|
|
28
|
-
readonly start: string | number;
|
|
29
|
-
readonly end: string | number;
|
|
30
|
-
}[];
|
|
31
|
-
}
|