@mongrov/data-access 0.1.0-alpha.1 → 0.1.0-alpha.3
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/dist/context.js +48 -11
- package/dist/context.js.map +1 -1
- package/dist/define.js +14 -9
- package/dist/define.js.map +1 -1
- package/dist/dispatcher.js +16 -12
- package/dist/dispatcher.js.map +1 -1
- package/dist/errors.js +9 -3
- package/dist/errors.js.map +1 -1
- package/dist/eslint/index.js +11 -4
- package/dist/eslint/index.js.map +1 -1
- package/dist/eslint/rules/no-storage-engine-imports.js +40 -3
- package/dist/eslint/rules/no-storage-engine-imports.js.map +1 -1
- package/dist/hooks.js +65 -25
- package/dist/hooks.js.map +1 -1
- package/dist/index.js +24 -8
- package/dist/index.js.map +1 -1
- package/dist/invalidation.js +15 -8
- package/dist/invalidation.js.map +1 -1
- package/dist/tenant.js +4 -1
- package/dist/tenant.js.map +1 -1
- package/dist/types.js +2 -1
- package/dist/types.js.map +1 -1
- package/package.json +8 -7
package/dist/context.js
CHANGED
|
@@ -1,4 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DataAccessProvider = DataAccessProvider;
|
|
37
|
+
exports.useDataAccessRuntime = useDataAccessRuntime;
|
|
38
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
2
39
|
/**
|
|
3
40
|
* DataAccessProvider (T-16) + internal context.
|
|
4
41
|
*
|
|
@@ -9,24 +46,24 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
9
46
|
*
|
|
10
47
|
* See data-access/spec.md §Registry pattern.
|
|
11
48
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
49
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
50
|
+
const React = __importStar(require("react"));
|
|
51
|
+
const errors_1 = require("./errors");
|
|
52
|
+
const invalidation_1 = require("./invalidation");
|
|
16
53
|
const DataAccessContext = React.createContext(null);
|
|
17
54
|
DataAccessContext.displayName = 'DataAccessContext';
|
|
18
|
-
|
|
55
|
+
function DataAccessProvider(props) {
|
|
19
56
|
const { registry, engines, context, bus: suppliedBus, queryClient: suppliedClient, children, } = props;
|
|
20
57
|
// Bus / client are created once per provider mount. Deliberately not
|
|
21
58
|
// memoized on the supplied identity — swapping either mid-lifetime is
|
|
22
59
|
// unsupported.
|
|
23
60
|
const busRef = React.useRef(null);
|
|
24
61
|
if (busRef.current === null) {
|
|
25
|
-
busRef.current = suppliedBus ?? createEventBus();
|
|
62
|
+
busRef.current = suppliedBus ?? (0, invalidation_1.createEventBus)();
|
|
26
63
|
}
|
|
27
64
|
const clientRef = React.useRef(null);
|
|
28
65
|
if (clientRef.current === null) {
|
|
29
|
-
clientRef.current = suppliedClient ?? new QueryClient();
|
|
66
|
+
clientRef.current = suppliedClient ?? new react_query_1.QueryClient();
|
|
30
67
|
}
|
|
31
68
|
const runtime = React.useMemo(() => ({
|
|
32
69
|
registry,
|
|
@@ -35,16 +72,16 @@ export function DataAccessProvider(props) {
|
|
|
35
72
|
queryClient: clientRef.current,
|
|
36
73
|
getContext: context,
|
|
37
74
|
}), [registry, engines, context]);
|
|
38
|
-
return (
|
|
75
|
+
return ((0, jsx_runtime_1.jsx)(DataAccessContext.Provider, { value: runtime, children: (0, jsx_runtime_1.jsx)(react_query_1.QueryClientProvider, { client: runtime.queryClient, children: children }) }));
|
|
39
76
|
}
|
|
40
77
|
/**
|
|
41
78
|
* Internal — used by every hook to reach the runtime. Throws a typed
|
|
42
79
|
* error when a hook is used outside a DataAccessProvider.
|
|
43
80
|
*/
|
|
44
|
-
|
|
81
|
+
function useDataAccessRuntime() {
|
|
45
82
|
const runtime = React.useContext(DataAccessContext);
|
|
46
83
|
if (runtime === null) {
|
|
47
|
-
throw new DataAccessError('engine_missing', 'data-access hook called outside <DataAccessProvider>');
|
|
84
|
+
throw new errors_1.DataAccessError('engine_missing', 'data-access hook called outside <DataAccessProvider>');
|
|
48
85
|
}
|
|
49
86
|
return runtime;
|
|
50
87
|
}
|
package/dist/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["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,CAC7B,CAAA;IAED,OAAO,CACL,uBAAC,iBAAiB,CAAC,QAAQ,IAAC,KAAK,EAAE,OAAO,YACxC,uBAAC,iCAAmB,IAAC,MAAM,EAAE,OAAO,CAAC,WAAW,YAC7C,QAAQ,GACW,GACK,CAC9B,CAAA;AACH,CAAC;AAED;;;GAGG;AACH,SAAgB,oBAAoB;IAClC,MAAM,OAAO,GAAG,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAA;IACnD,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,wBAAe,CACvB,gBAAgB,EAChB,sDAAsD,CACvD,CAAA;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC"}
|
package/dist/define.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Registry primitives — defineQuery / defineMutation / defineEvent.
|
|
3
4
|
*
|
|
@@ -7,12 +8,16 @@
|
|
|
7
8
|
*
|
|
8
9
|
* See data-access/spec.md §Define API.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.defineQuery = defineQuery;
|
|
13
|
+
exports.defineMutation = defineMutation;
|
|
14
|
+
exports.defineEvent = defineEvent;
|
|
15
|
+
const errors_1 = require("./errors");
|
|
11
16
|
/**
|
|
12
17
|
* Register a typed query. Runtime enforces the engine-specific required
|
|
13
18
|
* field so JS callers get a loud error even when TypeScript is skipped.
|
|
14
19
|
*/
|
|
15
|
-
|
|
20
|
+
function defineQuery(config) {
|
|
16
21
|
assertQueryEngineField(config);
|
|
17
22
|
return { __kind: 'query', config };
|
|
18
23
|
}
|
|
@@ -20,9 +25,9 @@ export function defineQuery(config) {
|
|
|
20
25
|
* Register a typed mutation. `exec` is required; `invalidates` patterns
|
|
21
26
|
* fire through the invalidation bus on success.
|
|
22
27
|
*/
|
|
23
|
-
|
|
28
|
+
function defineMutation(config) {
|
|
24
29
|
if (typeof config.exec !== 'function') {
|
|
25
|
-
throw new DataAccessError('define_config_invalid', 'defineMutation requires an `exec` function');
|
|
30
|
+
throw new errors_1.DataAccessError('define_config_invalid', 'defineMutation requires an `exec` function');
|
|
26
31
|
}
|
|
27
32
|
return { __kind: 'mutation', config };
|
|
28
33
|
}
|
|
@@ -30,30 +35,30 @@ export function defineMutation(config) {
|
|
|
30
35
|
* Register a typed event. Payload type is inferred at the point of use
|
|
31
36
|
* (via useAppEvent). No runtime state is captured here.
|
|
32
37
|
*/
|
|
33
|
-
|
|
38
|
+
function defineEvent() {
|
|
34
39
|
return { __kind: 'event' };
|
|
35
40
|
}
|
|
36
41
|
function assertQueryEngineField(config) {
|
|
37
42
|
switch (config.engine) {
|
|
38
43
|
case 'duckdb':
|
|
39
44
|
if (typeof config.sql !== 'string' || config.sql.length === 0) {
|
|
40
|
-
throw new DataAccessError('define_config_invalid', "defineQuery: engine 'duckdb' requires a non-empty `sql` string");
|
|
45
|
+
throw new errors_1.DataAccessError('define_config_invalid', "defineQuery: engine 'duckdb' requires a non-empty `sql` string");
|
|
41
46
|
}
|
|
42
47
|
return;
|
|
43
48
|
case 'rxdb':
|
|
44
49
|
if (typeof config.query !== 'function') {
|
|
45
|
-
throw new DataAccessError('define_config_invalid', "defineQuery: engine 'rxdb' requires a `query` function");
|
|
50
|
+
throw new errors_1.DataAccessError('define_config_invalid', "defineQuery: engine 'rxdb' requires a `query` function");
|
|
46
51
|
}
|
|
47
52
|
return;
|
|
48
53
|
case 'kv':
|
|
49
54
|
if (typeof config.keyBuilder !== 'function') {
|
|
50
|
-
throw new DataAccessError('define_config_invalid', "defineQuery: engine 'kv' requires a `keyBuilder` function");
|
|
55
|
+
throw new errors_1.DataAccessError('define_config_invalid', "defineQuery: engine 'kv' requires a `keyBuilder` function");
|
|
51
56
|
}
|
|
52
57
|
return;
|
|
53
58
|
default: {
|
|
54
59
|
// Exhaustiveness: if a new engine is added, TS surfaces this at compile time.
|
|
55
60
|
const exhaustive = config;
|
|
56
|
-
throw new DataAccessError('define_config_invalid', `defineQuery: unknown engine ${JSON.stringify(exhaustive)}`);
|
|
61
|
+
throw new errors_1.DataAccessError('define_config_invalid', `defineQuery: unknown engine ${JSON.stringify(exhaustive)}`);
|
|
57
62
|
}
|
|
58
63
|
}
|
|
59
64
|
}
|
package/dist/define.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"define.js","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;AAeH,kCAKC;AAMD,wCAUC;AAMD,kCAEC;AA1CD,qCAA0C;AAS1C;;;GAGG;AACH,SAAgB,WAAW,CACzB,MAAoC;IAEpC,sBAAsB,CAAC,MAAM,CAAC,CAAA;IAC9B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,CAAA;AACpC,CAAC;AAED;;;GAGG;AACH,SAAgB,cAAc,CAC5B,MAAuC;IAEvC,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;QACtC,MAAM,IAAI,wBAAe,CACvB,uBAAuB,EACvB,4CAA4C,CAC7C,CAAA;IACH,CAAC;IACD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,CAAA;AACvC,CAAC;AAED;;;GAGG;AACH,SAAgB,WAAW;IACzB,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAA;AAC5B,CAAC;AAED,SAAS,sBAAsB,CAC7B,MAAoC;IAEpC,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;QACtB,KAAK,QAAQ;YACX,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC9D,MAAM,IAAI,wBAAe,CACvB,uBAAuB,EACvB,gEAAgE,CACjE,CAAA;YACH,CAAC;YACD,OAAM;QACR,KAAK,MAAM;YACT,IAAI,OAAO,MAAM,CAAC,KAAK,KAAK,UAAU,EAAE,CAAC;gBACvC,MAAM,IAAI,wBAAe,CACvB,uBAAuB,EACvB,wDAAwD,CACzD,CAAA;YACH,CAAC;YACD,OAAM;QACR,KAAK,IAAI;YACP,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,EAAE,CAAC;gBAC5C,MAAM,IAAI,wBAAe,CACvB,uBAAuB,EACvB,2DAA2D,CAC5D,CAAA;YACH,CAAC;YACD,OAAM;QACR,OAAO,CAAC,CAAC,CAAC;YACR,8EAA8E;YAC9E,MAAM,UAAU,GAAU,MAAM,CAAA;YAChC,MAAM,IAAI,wBAAe,CACvB,uBAAuB,EACvB,+BAA+B,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,EAAE,CAC5D,CAAA;QACH,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/dist/dispatcher.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Engine dispatcher (T-06 · T-07 · T-08).
|
|
3
4
|
*
|
|
@@ -15,12 +16,15 @@
|
|
|
15
16
|
* Engines are provided as adapter objects (see EngineAdapters below).
|
|
16
17
|
* The dispatcher never imports @mongrov/analytics or @mongrov/db.
|
|
17
18
|
*/
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.executeQuery = executeQuery;
|
|
21
|
+
exports.runAuthorize = runAuthorize;
|
|
22
|
+
const errors_1 = require("./errors");
|
|
23
|
+
const tenant_1 = require("./tenant");
|
|
20
24
|
/**
|
|
21
25
|
* T-06 core — resolve a registered query and return typed output.
|
|
22
26
|
*/
|
|
23
|
-
|
|
27
|
+
async function executeQuery(def, input, ctx, engines) {
|
|
24
28
|
const parsedInput = parseInput(def.config.input, input);
|
|
25
29
|
await runAuthorize(def.config.authorize, parsedInput, ctx);
|
|
26
30
|
const raw = await dispatchByEngine(def.config, parsedInput, ctx, engines);
|
|
@@ -31,14 +35,14 @@ function parseInput(schema, input) {
|
|
|
31
35
|
return input;
|
|
32
36
|
const result = schema.safeParse(input);
|
|
33
37
|
if (!result.success) {
|
|
34
|
-
throw new DataAccessError('zod_parse_failed', `input failed schema validation: ${result.error.message}`, result.error);
|
|
38
|
+
throw new errors_1.DataAccessError('zod_parse_failed', `input failed schema validation: ${result.error.message}`, result.error);
|
|
35
39
|
}
|
|
36
40
|
return result.data;
|
|
37
41
|
}
|
|
38
42
|
function parseOutput(schema, raw) {
|
|
39
43
|
const result = schema.safeParse(raw);
|
|
40
44
|
if (!result.success) {
|
|
41
|
-
throw new DataAccessError('zod_parse_failed', `output failed schema validation: ${result.error.message}`, result.error);
|
|
45
|
+
throw new errors_1.DataAccessError('zod_parse_failed', `output failed schema validation: ${result.error.message}`, result.error);
|
|
42
46
|
}
|
|
43
47
|
return result.data;
|
|
44
48
|
}
|
|
@@ -46,12 +50,12 @@ function parseOutput(schema, raw) {
|
|
|
46
50
|
* T-07 — authorization gate. Runs the definition's `authorize` if
|
|
47
51
|
* present; a `false` result throws `AuthorizationError`.
|
|
48
52
|
*/
|
|
49
|
-
|
|
53
|
+
async function runAuthorize(authorize, input, ctx) {
|
|
50
54
|
if (!authorize)
|
|
51
55
|
return;
|
|
52
56
|
const allowed = await Promise.resolve(authorize(input, ctx));
|
|
53
57
|
if (!allowed) {
|
|
54
|
-
throw new AuthorizationError('authorization denied by query authorize hook');
|
|
58
|
+
throw new errors_1.AuthorizationError('authorization denied by query authorize hook');
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
async function dispatchByEngine(config, input, ctx, engines) {
|
|
@@ -64,26 +68,26 @@ async function dispatchByEngine(config, input, ctx, engines) {
|
|
|
64
68
|
return dispatchKv(config, input, engines.kv);
|
|
65
69
|
default: {
|
|
66
70
|
const exhaustive = config;
|
|
67
|
-
throw new DataAccessError('engine_missing', `unknown engine: ${JSON.stringify(exhaustive)}`);
|
|
71
|
+
throw new errors_1.DataAccessError('engine_missing', `unknown engine: ${JSON.stringify(exhaustive)}`);
|
|
68
72
|
}
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
function dispatchDuckdb(config, input, ctx, engine) {
|
|
72
76
|
if (!engine) {
|
|
73
|
-
throw new DataAccessError('engine_missing', "engine 'duckdb' is not wired in this dispatcher");
|
|
77
|
+
throw new errors_1.DataAccessError('engine_missing', "engine 'duckdb' is not wired in this dispatcher");
|
|
74
78
|
}
|
|
75
|
-
const params = mergeTenantParams(input, ctx);
|
|
79
|
+
const params = (0, tenant_1.mergeTenantParams)(input, ctx);
|
|
76
80
|
return engine.execute(config.sql, params);
|
|
77
81
|
}
|
|
78
82
|
function dispatchRxdb(config, input, engine) {
|
|
79
83
|
if (!engine) {
|
|
80
|
-
throw new DataAccessError('engine_missing', "engine 'rxdb' is not wired in this dispatcher");
|
|
84
|
+
throw new errors_1.DataAccessError('engine_missing', "engine 'rxdb' is not wired in this dispatcher");
|
|
81
85
|
}
|
|
82
86
|
return engine.execute(config, input);
|
|
83
87
|
}
|
|
84
88
|
async function dispatchKv(config, input, engine) {
|
|
85
89
|
if (!engine) {
|
|
86
|
-
throw new DataAccessError('engine_missing', "engine 'kv' is not wired in this dispatcher");
|
|
90
|
+
throw new errors_1.DataAccessError('engine_missing', "engine 'kv' is not wired in this dispatcher");
|
|
87
91
|
}
|
|
88
92
|
const key = config.keyBuilder(input);
|
|
89
93
|
return engine.get(key);
|
package/dist/dispatcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../src/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;
|
|
1
|
+
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../src/dispatcher.ts"],"names":[],"mappings":";AA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iB,EAAC,KAAK,EAAE,GAAG,CAAC,CAAA;IAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,CAAA;AAC3C,CAAC;AAED,SAAS,YAAY,CACnB,MAAwC,EACxC,KAAa,EACb,MAA8B;IAE9B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,wBAAe,CACvB,gBAAgB,EAChB,+CAA+C,CAChD,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AACtC,CAAC;AAED,KAAK,UAAU,UAAU,CACvB,MAAsC,EACtC,KAAa,EACb,MAA4B;IAE5B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,IAAI,wBAAe,CACvB,gBAAgB,EAChB,6CAA6C,CAC9C,CAAA;IACH,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAA;IACpC,OAAO,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;AACxB,CAAC"}
|
package/dist/errors.js
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Error taxonomy for @mongrov/data-access.
|
|
3
4
|
*
|
|
4
5
|
* Full code set fills in as later phases land. This file ships the class
|
|
5
6
|
* plus the codes stubs need on day one.
|
|
6
7
|
*/
|
|
7
|
-
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.NotImplementedError = exports.AuthorizationError = exports.DataAccessError = void 0;
|
|
10
|
+
class DataAccessError extends Error {
|
|
8
11
|
constructor(code, message, cause) {
|
|
9
12
|
super(message);
|
|
10
13
|
this.name = 'DataAccessError';
|
|
@@ -12,24 +15,27 @@ export class DataAccessError extends Error {
|
|
|
12
15
|
this.cause = cause;
|
|
13
16
|
}
|
|
14
17
|
}
|
|
18
|
+
exports.DataAccessError = DataAccessError;
|
|
15
19
|
/**
|
|
16
20
|
* Thrown when authorization hook rejects a query or mutation.
|
|
17
21
|
* See data-access/spec.md §Authorization.
|
|
18
22
|
*/
|
|
19
|
-
|
|
23
|
+
class AuthorizationError extends DataAccessError {
|
|
20
24
|
constructor(message, cause) {
|
|
21
25
|
super('authorization_denied', message, cause);
|
|
22
26
|
this.name = 'AuthorizationError';
|
|
23
27
|
}
|
|
24
28
|
}
|
|
29
|
+
exports.AuthorizationError = AuthorizationError;
|
|
25
30
|
/**
|
|
26
31
|
* Thrown by unimplemented stubs. Distinct class so tests can assert on
|
|
27
32
|
* "this surface isn't wired yet" without ambiguity against runtime errors.
|
|
28
33
|
*/
|
|
29
|
-
|
|
34
|
+
class NotImplementedError extends DataAccessError {
|
|
30
35
|
constructor(symbol) {
|
|
31
36
|
super('not_implemented', `${symbol} is not implemented in @mongrov/data-access@0.1.0-alpha.0`);
|
|
32
37
|
this.name = 'NotImplementedError';
|
|
33
38
|
}
|
|
34
39
|
}
|
|
40
|
+
exports.NotImplementedError = NotImplementedError;
|
|
35
41
|
//# sourceMappingURL=errors.js.map
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAUH,MAAa,eAAgB,SAAQ,KAAK;IAIxC,YAAY,IAAyB,EAAE,OAAe,EAAE,KAAe;QACrE,KAAK,CAAC,OAAO,CAAC,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAA;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;CACF;AAVD,0CAUC;AAED;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,eAAe;IACrD,YAAY,OAAe,EAAE,KAAe;QAC1C,KAAK,CAAC,sBAAsB,EAAE,OAAO,EAAE,KAAK,CAAC,CAAA;QAC7C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAA;IAClC,CAAC;CACF;AALD,gDAKC;AAED;;;GAGG;AACH,MAAa,mBAAoB,SAAQ,eAAe;IACtD,YAAY,MAAc;QACxB,KAAK,CACH,iBAAiB,EACjB,GAAG,MAAM,2DAA2D,CACrE,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;IACnC,CAAC;CACF;AARD,kDAQC"}
|
package/dist/eslint/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ESLint plugin barrel — `@mongrov/data-access/eslint`.
|
|
3
4
|
*
|
|
@@ -23,11 +24,17 @@
|
|
|
23
24
|
*
|
|
24
25
|
* See data-access/spec.md §ESLint plugin.
|
|
25
26
|
*/
|
|
26
|
-
|
|
27
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
28
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
29
|
+
};
|
|
30
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
+
exports.configs = exports.rules = void 0;
|
|
32
|
+
const no_storage_engine_imports_1 = __importDefault(require("./rules/no-storage-engine-imports"));
|
|
27
33
|
const PLUGIN_NAME = '@mongrov/data-access';
|
|
28
34
|
const rules = {
|
|
29
|
-
'no-storage-engine-imports':
|
|
35
|
+
'no-storage-engine-imports': no_storage_engine_imports_1.default,
|
|
30
36
|
};
|
|
37
|
+
exports.rules = rules;
|
|
31
38
|
const configs = {
|
|
32
39
|
recommended: {
|
|
33
40
|
plugins: [PLUGIN_NAME],
|
|
@@ -36,10 +43,10 @@ const configs = {
|
|
|
36
43
|
},
|
|
37
44
|
},
|
|
38
45
|
};
|
|
46
|
+
exports.configs = configs;
|
|
39
47
|
const plugin = {
|
|
40
48
|
rules,
|
|
41
49
|
configs,
|
|
42
50
|
};
|
|
43
|
-
|
|
44
|
-
export default plugin;
|
|
51
|
+
exports.default = plugin;
|
|
45
52
|
//# sourceMappingURL=index.js.map
|
package/dist/eslint/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eslint/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/eslint/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;;;;;;AAEH,kGAAsE;AAEtE,MAAM,WAAW,GAAG,sBAAsB,CAAA;AAE1C,MAAM,KAAK,GAAG;IACZ,2BAA2B,EAAE,mCAAsB;CAC3C,CAAA;AAgBD,sBAAK;AAdd,MAAM,OAAO,GAAG;IACd,WAAW,EAAE;QACX,OAAO,EAAE,CAAC,WAAW,CAAC;QACtB,KAAK,EAAE;YACL,CAAC,GAAG,WAAW,4BAA4B,CAAC,EAAE,OAAO;SACtD;KACF;CACO,CAAA;AAOM,0BAAO;AALvB,MAAM,MAAM,GAAG;IACb,KAAK;IACL,OAAO;CACR,CAAA;AAGD,kBAAe,MAAM,CAAA"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* ESLint rule — `no-storage-engine-imports`.
|
|
3
4
|
*
|
|
@@ -11,15 +12,52 @@
|
|
|
11
12
|
*
|
|
12
13
|
* See data-access/spec.md §ESLint plugin.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.DEFAULT_BLOCKED_PACKAGES = exports.DEFAULT_ALLOWED_DIRS = void 0;
|
|
50
|
+
const path = __importStar(require("node:path"));
|
|
15
51
|
/** Default block list — the three storage engines the spec forbids. */
|
|
16
52
|
const DEFAULT_BLOCKED_PACKAGES = [
|
|
17
53
|
'@mongrov/analytics',
|
|
18
54
|
'@mongrov/collab',
|
|
19
55
|
'@mongrov/db',
|
|
20
56
|
];
|
|
57
|
+
exports.DEFAULT_BLOCKED_PACKAGES = DEFAULT_BLOCKED_PACKAGES;
|
|
21
58
|
/** Default allow list — empty; apps supply their registry dirs. */
|
|
22
59
|
const DEFAULT_ALLOWED_DIRS = [];
|
|
60
|
+
exports.DEFAULT_ALLOWED_DIRS = DEFAULT_ALLOWED_DIRS;
|
|
23
61
|
const optionsSchema = {
|
|
24
62
|
type: 'object',
|
|
25
63
|
properties: {
|
|
@@ -140,6 +178,5 @@ function relativize(filename) {
|
|
|
140
178
|
return filename;
|
|
141
179
|
}
|
|
142
180
|
}
|
|
143
|
-
|
|
144
|
-
export { DEFAULT_ALLOWED_DIRS, DEFAULT_BLOCKED_PACKAGES };
|
|
181
|
+
exports.default = rule;
|
|
145
182
|
//# sourceMappingURL=no-storage-engine-imports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"no-storage-engine-imports.js","sourceRoot":"","sources":["../../../src/eslint/rules/no-storage-engine-imports.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG
|
|
1
|
+
{"version":3,"file":"no-storage-engine-imports.js","sourceRoot":"","sources":["../../../src/eslint/rules/no-storage-engine-imports.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGH,gDAAiC;AAOjC,uEAAuE;AACvE,MAAM,wBAAwB,GAAG;IAC/B,oBAAoB;IACpB,iBAAiB;IACjB,aAAa;CACd,CAAA;AA6I8B,4DAAwB;AA3IvD,mEAAmE;AACnE,MAAM,oBAAoB,GAAa,EAAE,CAAA;AA0IhC,oDAAoB;AAxI7B,MAAM,aAAa,GAAG;IACpB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,WAAW,EAAE;YACX,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACzB,WAAW,EACT,oLAAoL;SACvL;QACD,eAAe,EAAE;YACf,IAAI,EAAE,OAAO;YACb,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE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data-access/spec.md §Hooks.
|
|
13
14
|
*/
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
15
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
18
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
19
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
20
|
+
}
|
|
21
|
+
Object.defineProperty(o, k2, desc);
|
|
22
|
+
}) : (function(o, m, k, k2) {
|
|
23
|
+
if (k2 === undefined) k2 = k;
|
|
24
|
+
o[k2] = m[k];
|
|
25
|
+
}));
|
|
26
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
27
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
28
|
+
}) : function(o, v) {
|
|
29
|
+
o["default"] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
32
|
+
var ownKeys = function(o) {
|
|
33
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
34
|
+
var ar = [];
|
|
35
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
36
|
+
return ar;
|
|
37
|
+
};
|
|
38
|
+
return ownKeys(o);
|
|
39
|
+
};
|
|
40
|
+
return function (mod) {
|
|
41
|
+
if (mod && mod.__esModule) return mod;
|
|
42
|
+
var result = {};
|
|
43
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
44
|
+
__setModuleDefault(result, mod);
|
|
45
|
+
return result;
|
|
46
|
+
};
|
|
47
|
+
})();
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.DEFAULT_GC_TIME = exports.DEFAULT_STALE_TIME = void 0;
|
|
50
|
+
exports.useAppQuery = useAppQuery;
|
|
51
|
+
exports.useAppMutation = useAppMutation;
|
|
52
|
+
exports.useAppEvent = useAppEvent;
|
|
53
|
+
exports.useRequestContext = useRequestContext;
|
|
54
|
+
const react_query_1 = require("@tanstack/react-query");
|
|
55
|
+
const React = __importStar(require("react"));
|
|
56
|
+
const context_1 = require("./context");
|
|
57
|
+
const dispatcher_1 = require("./dispatcher");
|
|
58
|
+
const errors_1 = require("./errors");
|
|
19
59
|
/** T-18 — cache defaults per spec §Cache. Per-query overrides win. */
|
|
20
|
-
|
|
21
|
-
|
|
60
|
+
exports.DEFAULT_STALE_TIME = 30000;
|
|
61
|
+
exports.DEFAULT_GC_TIME = 300000;
|
|
22
62
|
/**
|
|
23
63
|
* T-11 (duckdb) + T-12 (rxdb) + T-13 (kv) — screen-facing query hook.
|
|
24
64
|
*
|
|
@@ -27,19 +67,19 @@ export const DEFAULT_GC_TIME = 300000;
|
|
|
27
67
|
* pushed into local state. `refetch` is a no-op (the observable
|
|
28
68
|
* drives updates).
|
|
29
69
|
*/
|
|
30
|
-
|
|
31
|
-
const runtime = useDataAccessRuntime();
|
|
70
|
+
function useAppQuery(name, input) {
|
|
71
|
+
const runtime = (0, context_1.useDataAccessRuntime)();
|
|
32
72
|
const def = lookupDefinition(runtime.registry.queries, 'query', name);
|
|
33
73
|
const engine = def.config.engine;
|
|
34
74
|
const isRxdb = engine === 'rxdb';
|
|
35
75
|
const queryKey = React.useMemo(() => [name, input], [name, input]);
|
|
36
76
|
// TanStack path — active for duckdb + kv, disabled for rxdb.
|
|
37
|
-
const query = useQuery({
|
|
77
|
+
const query = (0, react_query_1.useQuery)({
|
|
38
78
|
queryKey,
|
|
39
|
-
queryFn: () => executeQuery(def, input, runtime.getContext(), runtime.engines),
|
|
79
|
+
queryFn: () => (0, dispatcher_1.executeQuery)(def, input, runtime.getContext(), runtime.engines),
|
|
40
80
|
enabled: !isRxdb,
|
|
41
|
-
staleTime: def.config.staleTime ?? DEFAULT_STALE_TIME,
|
|
42
|
-
gcTime: def.config.gcTime ?? DEFAULT_GC_TIME,
|
|
81
|
+
staleTime: def.config.staleTime ?? exports.DEFAULT_STALE_TIME,
|
|
82
|
+
gcTime: def.config.gcTime ?? exports.DEFAULT_GC_TIME,
|
|
43
83
|
});
|
|
44
84
|
// rxdb path — external state driven by observable emissions.
|
|
45
85
|
const [rxState, setRxState] = React.useState({ data: undefined, loading: true, error: null });
|
|
@@ -51,7 +91,7 @@ export function useAppQuery(name, input) {
|
|
|
51
91
|
setRxState({
|
|
52
92
|
data: undefined,
|
|
53
93
|
loading: false,
|
|
54
|
-
error: new DataAccessError('engine_missing', "engine 'rxdb' is not wired in this dispatcher"),
|
|
94
|
+
error: new errors_1.DataAccessError('engine_missing', "engine 'rxdb' is not wired in this dispatcher"),
|
|
55
95
|
});
|
|
56
96
|
return;
|
|
57
97
|
}
|
|
@@ -73,7 +113,7 @@ export function useAppQuery(name, input) {
|
|
|
73
113
|
setRxState({
|
|
74
114
|
data: undefined,
|
|
75
115
|
loading: false,
|
|
76
|
-
error: new DataAccessError('zod_parse_failed', `query "${name}" output failed schema validation: ${parsed.error.message}`, parsed.error),
|
|
116
|
+
error: new errors_1.DataAccessError('zod_parse_failed', `query "${name}" output failed schema validation: ${parsed.error.message}`, parsed.error),
|
|
77
117
|
});
|
|
78
118
|
}
|
|
79
119
|
},
|
|
@@ -139,15 +179,15 @@ export function useAppQuery(name, input) {
|
|
|
139
179
|
* is defined, the returned `data` reflects the optimistic value while
|
|
140
180
|
* the mutation is pending and reverts on failure.
|
|
141
181
|
*/
|
|
142
|
-
|
|
143
|
-
const runtime = useDataAccessRuntime();
|
|
182
|
+
function useAppMutation(name) {
|
|
183
|
+
const runtime = (0, context_1.useDataAccessRuntime)();
|
|
144
184
|
const def = lookupDefinition(runtime.registry.mutations, 'mutation', name);
|
|
145
185
|
const [optimisticValue, setOptimisticValue] = React.useState(undefined);
|
|
146
|
-
const mutation = useMutation({
|
|
186
|
+
const mutation = (0, react_query_1.useMutation)({
|
|
147
187
|
mutationFn: async (input) => {
|
|
148
188
|
const ctx = runtime.getContext();
|
|
149
189
|
const parsedInput = parseWithSchema(def.config.input, input, 'input', name);
|
|
150
|
-
await runAuthorize(def.config.authorize, parsedInput, ctx);
|
|
190
|
+
await (0, dispatcher_1.runAuthorize)(def.config.authorize, parsedInput, ctx);
|
|
151
191
|
const raw = await def.config.exec(parsedInput, ctx);
|
|
152
192
|
return parseWithSchema(def.config.output, raw, 'output', name);
|
|
153
193
|
},
|
|
@@ -192,8 +232,8 @@ export function useAppMutation(name) {
|
|
|
192
232
|
* The handler ref is kept fresh so callers may pass unstable closures
|
|
193
233
|
* without churning the subscription.
|
|
194
234
|
*/
|
|
195
|
-
|
|
196
|
-
const runtime = useDataAccessRuntime();
|
|
235
|
+
function useAppEvent(name, handler) {
|
|
236
|
+
const runtime = (0, context_1.useDataAccessRuntime)();
|
|
197
237
|
const handlerRef = React.useRef(handler);
|
|
198
238
|
React.useEffect(() => {
|
|
199
239
|
handlerRef.current = handler;
|
|
@@ -210,15 +250,15 @@ export function useAppEvent(name, handler) {
|
|
|
210
250
|
* The provider's `context` callback is invoked on every read so
|
|
211
251
|
* callers pick up session updates without re-mounting.
|
|
212
252
|
*/
|
|
213
|
-
|
|
214
|
-
const runtime = useDataAccessRuntime();
|
|
253
|
+
function useRequestContext() {
|
|
254
|
+
const runtime = (0, context_1.useDataAccessRuntime)();
|
|
215
255
|
return runtime.getContext();
|
|
216
256
|
}
|
|
217
257
|
// --- helpers ---------------------------------------------------------
|
|
218
258
|
function lookupDefinition(bag, label, name) {
|
|
219
259
|
const def = bag[name];
|
|
220
260
|
if (!def) {
|
|
221
|
-
throw new DataAccessError('engine_missing', `no ${label} named "${name}" is registered`);
|
|
261
|
+
throw new errors_1.DataAccessError('engine_missing', `no ${label} named "${name}" is registered`);
|
|
222
262
|
}
|
|
223
263
|
return def;
|
|
224
264
|
}
|
|
@@ -227,7 +267,7 @@ function parseWithSchema(schema, value, side, name) {
|
|
|
227
267
|
return value;
|
|
228
268
|
const result = schema.safeParse(value);
|
|
229
269
|
if (!result.success) {
|
|
230
|
-
throw new DataAccessError('zod_parse_failed', `mutation "${name}" ${side} failed schema validation: ${result.error.message}`, result.error);
|
|
270
|
+
throw new errors_1.DataAccessError('zod_parse_failed', `mutation "${name}" ${side} failed schema validation: ${result.error.message}`, result.error);
|
|
231
271
|
}
|
|
232
272
|
return result.data;
|
|
233
273
|
}
|
package/dist/hooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../src/hooks.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;GAYG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyDH,kCAkIC;AAWD,wCA6DC;AAUD,kCAiBC;AAOD,8CAGC;AAtSD,uDAA6D;AAC7D,6CAA8B;AAG9B,uCAAgD;AAChD,6CAAyD;AACzD,qCAA0C;AAQ1C,sEAAsE;AACzD,QAAA,kBAAkB,GAAG,KAAM,CAAA;AAC3B,QAAA,eAAe,GAAG,MAAO,CAAA;AA+BtC;;;;;;;GAOG;AACH,SAAgB,WAAW,CACzB,IAAY,EACZ,KAAc;IAEd,MAAM,OAAO,GAAG,IAAA,8BAAoB,GAAE,CAAA;IACtC,MAAM,GAAG,GAAG,gBAAgB,CAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO,EACxB,OAAO,EACP,IAAI,CACL,CAAA;IACD,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,MAAM,CAAA;IAChC,MAAM,MAAM,GAAG,MAAM,KAAK,MAAM,CAAA;IAEhC,MAAM,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,C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AAG,CAAA;IACZ,CAAC,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC,CAAA;AACzB,CAAC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB;IAC/B,MAAM,OAAO,GAAG,IAAA,8BAAoB,GAAE,CAAA;IACtC,OAAO,OAAO,CAAC,UAAU,EAAE,CAAA;AAC7B,CAAC;AAED,wEAAwE;AAExE,SAAS,gBAAgB,CACvB,GAA4B,EAC5B,KAA2B,EAC3B,IAAY;IAEZ,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,CAAA;IACrB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,wBAAe,CACvB,gBAAgB,EAChB,MAAM,KAAK,WAAW,IAAI,iBAAiB,CAC5C,CAAA;IACH,CAAC;IACD,OAAO,GAAQ,CAAA;AACjB,CAAC;AAED,SAAS,eAAe,CACtB,MAAgC,EAChC,KAAc,EACd,IAAwB,EACxB,IAAY;IAEZ,IAAI,CAAC,MAAM;QAAE,OAAO,KAAU,CAAA;IAC9B,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IACtC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,wBAAe,CACvB,kBAAkB,EAClB,aAAa,IAAI,KAAK,IAAI,8BAA8B,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAC9E,MAAM,CAAC,KAAK,CACb,CAAA;IACH,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAAA;AACpB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Public barrel — @mongrov/data-access.
|
|
3
4
|
*
|
|
@@ -5,12 +6,27 @@
|
|
|
5
6
|
* behavior arrives in later tasks; every callable currently throws
|
|
6
7
|
* NotImplementedError.
|
|
7
8
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
21
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
22
|
+
};
|
|
23
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
|
+
__exportStar(require("./errors"), exports);
|
|
25
|
+
__exportStar(require("./types"), exports);
|
|
26
|
+
__exportStar(require("./define"), exports);
|
|
27
|
+
__exportStar(require("./dispatcher"), exports);
|
|
28
|
+
__exportStar(require("./hooks"), exports);
|
|
29
|
+
__exportStar(require("./invalidation"), exports);
|
|
30
|
+
__exportStar(require("./context"), exports);
|
|
31
|
+
__exportStar(require("./tenant"), exports);
|
|
16
32
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;AAEH,2CAAwB;AACxB,0CAAuB;AACvB,2CAAwB;AACxB,+CAA4B;AAC5B,0CAAuB;AACvB,iDAA8B;AAC9B,4CAAyB;AACzB,2CAAwB"}
|
package/dist/invalidation.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Invalidation event bus.
|
|
3
4
|
*
|
|
@@ -12,10 +13,16 @@
|
|
|
12
13
|
*
|
|
13
14
|
* See data-access/spec.md §Invalidation event bus for the matching table.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.createEventBus = createEventBus;
|
|
21
|
+
exports.compileGlob = compileGlob;
|
|
22
|
+
const mitt_1 = __importDefault(require("mitt"));
|
|
23
|
+
const errors_1 = require("./errors");
|
|
24
|
+
function createEventBus() {
|
|
25
|
+
const exact = (0, mitt_1.default)();
|
|
19
26
|
const patterns = new Set();
|
|
20
27
|
return {
|
|
21
28
|
emit(name, payload) {
|
|
@@ -40,7 +47,7 @@ export function createEventBus() {
|
|
|
40
47
|
},
|
|
41
48
|
subscribe(name, handler) {
|
|
42
49
|
if (typeof name !== 'string' || name.length === 0) {
|
|
43
|
-
throw new DataAccessError('invalid_pattern', 'subscribe: event name must be a non-empty string');
|
|
50
|
+
throw new errors_1.DataAccessError('invalid_pattern', 'subscribe: event name must be a non-empty string');
|
|
44
51
|
}
|
|
45
52
|
const wrapped = (payload) => {
|
|
46
53
|
try {
|
|
@@ -77,14 +84,14 @@ export function createEventBus() {
|
|
|
77
84
|
*
|
|
78
85
|
* Empty patterns and empty segments are rejected. Case-sensitive.
|
|
79
86
|
*/
|
|
80
|
-
|
|
87
|
+
function compileGlob(pattern) {
|
|
81
88
|
if (typeof pattern !== 'string' || pattern.length === 0) {
|
|
82
|
-
throw new DataAccessError('invalid_pattern', 'subscribePattern: pattern must be a non-empty string');
|
|
89
|
+
throw new errors_1.DataAccessError('invalid_pattern', 'subscribePattern: pattern must be a non-empty string');
|
|
83
90
|
}
|
|
84
91
|
const segments = pattern.split(':');
|
|
85
92
|
const parts = segments.map((seg) => {
|
|
86
93
|
if (seg.length === 0) {
|
|
87
|
-
throw new DataAccessError('invalid_pattern', `subscribePattern: empty segment in pattern ${JSON.stringify(pattern)}`);
|
|
94
|
+
throw new errors_1.DataAccessError('invalid_pattern', `subscribePattern: empty segment in pattern ${JSON.stringify(pattern)}`);
|
|
88
95
|
}
|
|
89
96
|
if (seg === '**')
|
|
90
97
|
return '.+';
|
package/dist/invalidation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invalidation.js","sourceRoot":"","sources":["../src/invalidation.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"invalidation.js","sourceRoot":"","sources":["../src/invalidation.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;;;AAiBH,wCA+DC;AAaD,kCAoBC;AA/GD,gDAAyC;AAEzC,qCAA0C;AAa1C,SAAgB,cAAc;IAC5B,MAAM,KAAK,GAAwB,IAAA,cAAI,GAAc,CAAA;IACrD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAgB,CAAA;IAExC,OAAO;QACL,IAAI,CAAI,IAAY,EAAE,OAAU;YAC9B,oEAAoE;YACpE,oEAAoE;YACpE,IAAI,CAAC;gBACH,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,OAAkB,CAAC,CAAA;YACtC,CAAC;YACD,OAAO,GAAG,EAAE,CAAC;gBACX,kBAAkB,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;YAC/B,CAAC;YACD,KAAK,MAAM,KAAK,IAAI,QAAQ,EAAE,CAAC;gBAC7B,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC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10
11
|
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.mergeTenantParams = mergeTenantParams;
|
|
11
14
|
/**
|
|
12
15
|
* Merge caller input with `{ brand, familyId }` from the RequestContext.
|
|
13
16
|
* Caller keys win on collision (so an explicit override is possible in
|
|
14
17
|
* tests) but the tenant fields are always present in the result.
|
|
15
18
|
*/
|
|
16
|
-
|
|
19
|
+
function mergeTenantParams(input, ctx) {
|
|
17
20
|
const base = {
|
|
18
21
|
brand: ctx.brand,
|
|
19
22
|
familyId: ctx.familyId,
|
package/dist/tenant.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tenant.js","sourceRoot":"","sources":["../src/tenant.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;
|
|
1
|
+
{"version":3,"file":"tenant.js","sourceRoot":"","sources":["../src/tenant.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;AASH,8CAgBC;AArBD;;;;GAIG;AACH,SAAgB,iBAAiB,CAC/B,KAAc,EACd,GAAmB;IAEnB,MAAM,IAAI,GAA4B;QACpC,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,QAAQ,EAAE,GAAG,CAAC,QAAQ;KACvB,CAAA;IACD,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,IAAI,CAAA;IACtD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,qEAAqE;QACrE,qEAAqE;QACrE,iDAAiD;QACjD,OAAO,IAAI,CAAA;IACb,CAAC;IACD,OAAO,EAAE,GAAI,KAAiC,EAAE,GAAG,IAAI,EAAE,CAAA;AAC3D,CAAC"}
|
package/dist/types.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
/**
|
|
2
3
|
* Public type surface for @mongrov/data-access.
|
|
3
4
|
*
|
|
@@ -7,5 +8,5 @@
|
|
|
7
8
|
*
|
|
8
9
|
* See data-access/spec.md §Define API, §Engine dispatch.
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
12
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mongrov/data-access",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.3",
|
|
4
4
|
"description": "Named query/mutation/event registry with engine dispatch for @mongrov apps",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
27
|
"types": "./dist/index.d.ts",
|
|
28
|
-
"
|
|
28
|
+
"require": "./dist/index.js",
|
|
29
29
|
"default": "./dist/index.js"
|
|
30
30
|
},
|
|
31
31
|
"./eslint": {
|
|
32
32
|
"types": "./dist/eslint/index.d.ts",
|
|
33
|
-
"
|
|
33
|
+
"require": "./dist/eslint/index.js",
|
|
34
34
|
"default": "./dist/eslint/index.js"
|
|
35
35
|
}
|
|
36
36
|
},
|
|
@@ -48,8 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"mitt": "^3.0.1",
|
|
51
|
-
"xstate": "^5.30.0"
|
|
52
|
-
"zod": "^3.23.8"
|
|
51
|
+
"xstate": "^5.30.0"
|
|
53
52
|
},
|
|
54
53
|
"peerDependencies": {
|
|
55
54
|
"@mongrov/analytics": "workspace:*",
|
|
@@ -58,7 +57,8 @@
|
|
|
58
57
|
"@tanstack/react-query": ">=5",
|
|
59
58
|
"eslint": ">=8",
|
|
60
59
|
"react": ">=19",
|
|
61
|
-
"react-native": ">=0.81"
|
|
60
|
+
"react-native": ">=0.81",
|
|
61
|
+
"zod": "^3.23.8 || ^4.0.0"
|
|
62
62
|
},
|
|
63
63
|
"peerDependenciesMeta": {
|
|
64
64
|
"@mongrov/analytics": {
|
|
@@ -87,6 +87,7 @@
|
|
|
87
87
|
"react": "^18.3.1",
|
|
88
88
|
"react-dom": "^18.3.1",
|
|
89
89
|
"typescript": "^5.9.3",
|
|
90
|
-
"vitest": "^2.1.9"
|
|
90
|
+
"vitest": "^2.1.9",
|
|
91
|
+
"zod": "^3.23.8"
|
|
91
92
|
}
|
|
92
93
|
}
|