@datakable/core 2.0.2 → 2.0.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/{codes-AX8XkMNY.d.cts → codes-4sYQv_7J.d.cts} +36 -10
- package/dist/{codes-AX8XkMNY.d.ts → codes-4sYQv_7J.d.ts} +36 -10
- package/dist/column-filters.d.cts +2 -2
- package/dist/column-filters.d.ts +2 -2
- package/dist/diagnostics/build.cjs +1 -1
- package/dist/diagnostics/build.cjs.map +1 -1
- package/dist/diagnostics/build.js +2 -2
- package/dist/diagnostics/build.js.map +1 -1
- package/dist/diagnostics/console.cjs +15 -4
- package/dist/diagnostics/console.cjs.map +1 -1
- package/dist/diagnostics/console.js +15 -4
- package/dist/diagnostics/console.js.map +1 -1
- package/dist/diagnostics/prose.cjs +10 -1
- package/dist/diagnostics/prose.cjs.map +1 -1
- package/dist/diagnostics/prose.js +9 -1
- package/dist/diagnostics/prose.js.map +1 -1
- package/dist/{explain-pKAnnxEW.d.cts → explain-DmwN_RG9.d.cts} +11 -4
- package/dist/{explain-BVE3ln3G.d.ts → explain-Dr3SmMNY.d.ts} +11 -4
- package/dist/feature/install.cjs +2 -1
- package/dist/feature/install.cjs.map +1 -1
- package/dist/feature/install.js +2 -1
- package/dist/feature/install.js.map +1 -1
- package/dist/feature/slice-guard.cjs +76 -0
- package/dist/feature/slice-guard.cjs.map +1 -0
- package/dist/feature/slice-guard.js +50 -0
- package/dist/feature/slice-guard.js.map +1 -0
- package/dist/features/column-filters/codes.cjs +2 -19
- package/dist/features/column-filters/codes.cjs.map +1 -1
- package/dist/features/column-filters/codes.js +2 -19
- package/dist/features/column-filters/codes.js.map +1 -1
- package/dist/features/column-filters/column-filters.cjs +37 -22
- package/dist/features/column-filters/column-filters.cjs.map +1 -1
- package/dist/features/column-filters/column-filters.js +37 -22
- package/dist/features/column-filters/column-filters.js.map +1 -1
- package/dist/features/column-filters/match.cjs +6 -2
- package/dist/features/column-filters/match.cjs.map +1 -1
- package/dist/features/column-filters/match.js +6 -2
- package/dist/features/column-filters/match.js.map +1 -1
- package/dist/features/pagination/pagination.cjs +2 -2
- package/dist/features/pagination/pagination.cjs.map +1 -1
- package/dist/features/pagination/pagination.js +2 -2
- package/dist/features/pagination/pagination.js.map +1 -1
- package/dist/features/search/codes.cjs +18 -2
- package/dist/features/search/codes.cjs.map +1 -1
- package/dist/features/search/codes.js +16 -1
- package/dist/features/search/codes.js.map +1 -1
- package/dist/features/search/search-engine.cjs +24 -5
- package/dist/features/search/search-engine.cjs.map +1 -1
- package/dist/features/search/search-engine.js +25 -6
- package/dist/features/search/search-engine.js.map +1 -1
- package/dist/features/sorting/sorting.cjs +55 -24
- package/dist/features/sorting/sorting.cjs.map +1 -1
- package/dist/features/sorting/sorting.js +55 -24
- package/dist/features/sorting/sorting.js.map +1 -1
- package/dist/index.d.cts +26 -17
- package/dist/index.d.ts +26 -17
- package/dist/intercept/runtime.cjs +3 -2
- package/dist/intercept/runtime.cjs.map +1 -1
- package/dist/intercept/runtime.js +3 -2
- package/dist/intercept/runtime.js.map +1 -1
- package/dist/messages/index.cjs +2 -0
- package/dist/messages/index.cjs.map +1 -1
- package/dist/messages/index.js +2 -0
- package/dist/messages/index.js.map +1 -1
- package/dist/pagination.d.cts +2 -2
- package/dist/pagination.d.ts +2 -2
- package/dist/schema.d.cts +2 -2
- package/dist/schema.d.ts +2 -2
- package/dist/{search-async-entry-ByMJbHjc.d.cts → search-async-entry-BiemO3JT.d.cts} +2 -2
- package/dist/{search-async-entry-CFQODE08.d.ts → search-async-entry-GRj0E06n.d.ts} +2 -2
- package/dist/search-async.d.cts +3 -3
- package/dist/search-async.d.ts +3 -3
- package/dist/search.d.cts +4 -4
- package/dist/search.d.ts +4 -4
- package/dist/server.d.cts +3 -3
- package/dist/server.d.ts +3 -3
- package/dist/sorting.d.cts +2 -2
- package/dist/sorting.d.ts +2 -2
- package/dist/source/async-control.cjs +2 -1
- package/dist/source/async-control.cjs.map +1 -1
- package/dist/source/async-control.js +2 -1
- package/dist/source/async-control.js.map +1 -1
- package/dist/source/fetcher.cjs.map +1 -1
- package/dist/source/fetcher.js.map +1 -1
- package/dist/source/server.cjs +58 -5
- package/dist/source/server.cjs.map +1 -1
- package/dist/source/server.js +58 -5
- package/dist/source/server.js.map +1 -1
- package/dist/table/create-table.cjs +30 -20
- package/dist/table/create-table.cjs.map +1 -1
- package/dist/table/create-table.js +30 -20
- package/dist/table/create-table.js.map +1 -1
- package/dist/table/index.cjs +3 -0
- package/dist/table/index.cjs.map +1 -1
- package/dist/table/index.js +5 -1
- package/dist/table/index.js.map +1 -1
- package/dist/table/state-codes.cjs +72 -0
- package/dist/table/state-codes.cjs.map +1 -0
- package/dist/table/state-codes.js +45 -0
- package/dist/table/state-codes.js.map +1 -0
- package/dist/table/types.cjs.map +1 -1
- package/dist/table/types.js.map +1 -1
- package/dist/validity.d.cts +2 -2
- package/dist/validity.d.ts +2 -2
- package/dist/version.cjs +1 -1
- package/dist/version.cjs.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
- package/dist/ingest/test-schemas.cjs +0 -73
- package/dist/ingest/test-schemas.cjs.map +0 -1
- package/dist/ingest/test-schemas.js +0 -46
- package/dist/ingest/test-schemas.js.map +0 -1
package/dist/version.cjs
CHANGED
package/dist/version.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/version.ts","../package.json"],"sourcesContent":["// Read from package.json at build time (the bundler inlines the one field), so a release never\n// ships a stale hard-coded version.\nimport { version } from '../package.json'\n\n/** The `@datakable/core` version (`context.package`, docs URLs, the global version registry). */\nexport const VERSION: string = version\n","{\n \"name\": \"@datakable/core\",\n \"version\": \"2.0.
|
|
1
|
+
{"version":3,"sources":["../src/version.ts","../package.json"],"sourcesContent":["// Read from package.json at build time (the bundler inlines the one field), so a release never\n// ships a stale hard-coded version.\nimport { version } from '../package.json'\n\n/** The `@datakable/core` version (`context.package`, docs URLs, the global version registry). */\nexport const VERSION: string = version\n","{\n \"name\": \"@datakable/core\",\n \"version\": \"2.0.3\",\n \"description\": \"Headless, framework-agnostic core of DataKable — table state, sorting, filtering and types.\",\n \"license\": \"MIT\",\n \"author\": \"Supakit Kitjanabumrungsak\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/Ink01101011/datakable.git\",\n \"directory\": \"packages/core\"\n },\n \"homepage\": \"https://github.com/Ink01101011/datakable#readme\",\n \"bugs\": \"https://github.com/Ink01101011/datakable/issues\",\n \"keywords\": [\n \"react\",\n \"react-table\",\n \"datatable\",\n \"data-table\",\n \"data-grid\",\n \"datagrid\",\n \"table\",\n \"typescript\",\n \"type-safe\",\n \"headless\",\n \"headless-ui\",\n \"zero-config\",\n \"sorting\",\n \"filtering\",\n \"search\",\n \"pagination\",\n \"framework-agnostic\",\n \"vanilla-js\",\n \"table-state\"\n ],\n \"type\": \"module\",\n \"sideEffects\": [\n \"./dist/messages/index.js\",\n \"./dist/messages/index.cjs\",\n \"./dist/diagnostics/process-guard.js\",\n \"./dist/diagnostics/process-guard.cjs\"\n ],\n \"engines\": {\n \"node\": \">=18.18.0\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"column-filters\": [\n \"./dist/column-filters.d.ts\"\n ],\n \"validity\": [\n \"./dist/validity.d.ts\"\n ],\n \"search\": [\n \"./dist/search.d.ts\"\n ],\n \"sorting\": [\n \"./dist/sorting.d.ts\"\n ],\n \"pagination\": [\n \"./dist/pagination.d.ts\"\n ],\n \"messages\": [\n \"./dist/messages.d.ts\"\n ],\n \"schema\": [\n \"./dist/schema.d.ts\"\n ],\n \"search-async\": [\n \"./dist/search-async.d.ts\"\n ],\n \"server\": [\n \"./dist/server.d.ts\"\n ]\n }\n },\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./column-filters\": {\n \"import\": {\n \"types\": \"./dist/column-filters.d.ts\",\n \"default\": \"./dist/features/column-filters/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/column-filters.d.cts\",\n \"default\": \"./dist/features/column-filters/index.cjs\"\n }\n },\n \"./validity\": {\n \"import\": {\n \"types\": \"./dist/validity.d.ts\",\n \"default\": \"./dist/features/validity/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/validity.d.cts\",\n \"default\": \"./dist/features/validity/index.cjs\"\n }\n },\n \"./search\": {\n \"import\": {\n \"types\": \"./dist/search.d.ts\",\n \"default\": \"./dist/features/search/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/search.d.cts\",\n \"default\": \"./dist/features/search/index.cjs\"\n }\n },\n \"./sorting\": {\n \"import\": {\n \"types\": \"./dist/sorting.d.ts\",\n \"default\": \"./dist/features/sorting/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/sorting.d.cts\",\n \"default\": \"./dist/features/sorting/index.cjs\"\n }\n },\n \"./pagination\": {\n \"import\": {\n \"types\": \"./dist/pagination.d.ts\",\n \"default\": \"./dist/features/pagination/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/pagination.d.cts\",\n \"default\": \"./dist/features/pagination/index.cjs\"\n }\n },\n \"./messages\": {\n \"import\": {\n \"types\": \"./dist/messages.d.ts\",\n \"default\": \"./dist/messages/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/messages.d.cts\",\n \"default\": \"./dist/messages/index.cjs\"\n }\n },\n \"./schema\": {\n \"import\": {\n \"types\": \"./dist/schema.d.ts\",\n \"default\": \"./dist/ingest/schema-entry.js\"\n },\n \"require\": {\n \"types\": \"./dist/schema.d.cts\",\n \"default\": \"./dist/ingest/schema-entry.cjs\"\n }\n },\n \"./search-async\": {\n \"import\": {\n \"types\": \"./dist/search-async.d.ts\",\n \"default\": \"./dist/features/search/search-async-entry.js\"\n },\n \"require\": {\n \"types\": \"./dist/search-async.d.cts\",\n \"default\": \"./dist/features/search/search-async-entry.cjs\"\n }\n },\n \"./server\": {\n \"import\": {\n \"types\": \"./dist/server.d.ts\",\n \"default\": \"./dist/source/server-entry.js\"\n },\n \"require\": {\n \"types\": \"./dist/server.d.cts\",\n \"default\": \"./dist/source/server-entry.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup && node scripts/postbuild.mjs\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"check:pkg\": \"publint --strict && attw --pack . && node scripts/check-catalog.mjs\",\n \"check:catalog\": \"node scripts/check-catalog.mjs\"\n },\n \"dependencies\": {\n \"ex-search\": \"1.1.1\",\n \"exsorted\": \"1.2.3\",\n \"kk-debounce\": \"1.1.0\"\n },\n \"devDependencies\": {\n \"esbuild\": \"0.27.7\"\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEE,cAAW;;;ADGN,IAAM,UAAkB;","names":[]}
|
package/dist/version.js
CHANGED
package/dist/version.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../package.json","../src/version.ts"],"sourcesContent":["{\n \"name\": \"@datakable/core\",\n \"version\": \"2.0.
|
|
1
|
+
{"version":3,"sources":["../package.json","../src/version.ts"],"sourcesContent":["{\n \"name\": \"@datakable/core\",\n \"version\": \"2.0.3\",\n \"description\": \"Headless, framework-agnostic core of DataKable — table state, sorting, filtering and types.\",\n \"license\": \"MIT\",\n \"author\": \"Supakit Kitjanabumrungsak\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/Ink01101011/datakable.git\",\n \"directory\": \"packages/core\"\n },\n \"homepage\": \"https://github.com/Ink01101011/datakable#readme\",\n \"bugs\": \"https://github.com/Ink01101011/datakable/issues\",\n \"keywords\": [\n \"react\",\n \"react-table\",\n \"datatable\",\n \"data-table\",\n \"data-grid\",\n \"datagrid\",\n \"table\",\n \"typescript\",\n \"type-safe\",\n \"headless\",\n \"headless-ui\",\n \"zero-config\",\n \"sorting\",\n \"filtering\",\n \"search\",\n \"pagination\",\n \"framework-agnostic\",\n \"vanilla-js\",\n \"table-state\"\n ],\n \"type\": \"module\",\n \"sideEffects\": [\n \"./dist/messages/index.js\",\n \"./dist/messages/index.cjs\",\n \"./dist/diagnostics/process-guard.js\",\n \"./dist/diagnostics/process-guard.cjs\"\n ],\n \"engines\": {\n \"node\": \">=18.18.0\"\n },\n \"main\": \"./dist/index.cjs\",\n \"module\": \"./dist/index.js\",\n \"types\": \"./dist/index.d.ts\",\n \"typesVersions\": {\n \"*\": {\n \"column-filters\": [\n \"./dist/column-filters.d.ts\"\n ],\n \"validity\": [\n \"./dist/validity.d.ts\"\n ],\n \"search\": [\n \"./dist/search.d.ts\"\n ],\n \"sorting\": [\n \"./dist/sorting.d.ts\"\n ],\n \"pagination\": [\n \"./dist/pagination.d.ts\"\n ],\n \"messages\": [\n \"./dist/messages.d.ts\"\n ],\n \"schema\": [\n \"./dist/schema.d.ts\"\n ],\n \"search-async\": [\n \"./dist/search-async.d.ts\"\n ],\n \"server\": [\n \"./dist/server.d.ts\"\n ]\n }\n },\n \"exports\": {\n \".\": {\n \"import\": {\n \"types\": \"./dist/index.d.ts\",\n \"default\": \"./dist/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/index.d.cts\",\n \"default\": \"./dist/index.cjs\"\n }\n },\n \"./column-filters\": {\n \"import\": {\n \"types\": \"./dist/column-filters.d.ts\",\n \"default\": \"./dist/features/column-filters/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/column-filters.d.cts\",\n \"default\": \"./dist/features/column-filters/index.cjs\"\n }\n },\n \"./validity\": {\n \"import\": {\n \"types\": \"./dist/validity.d.ts\",\n \"default\": \"./dist/features/validity/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/validity.d.cts\",\n \"default\": \"./dist/features/validity/index.cjs\"\n }\n },\n \"./search\": {\n \"import\": {\n \"types\": \"./dist/search.d.ts\",\n \"default\": \"./dist/features/search/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/search.d.cts\",\n \"default\": \"./dist/features/search/index.cjs\"\n }\n },\n \"./sorting\": {\n \"import\": {\n \"types\": \"./dist/sorting.d.ts\",\n \"default\": \"./dist/features/sorting/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/sorting.d.cts\",\n \"default\": \"./dist/features/sorting/index.cjs\"\n }\n },\n \"./pagination\": {\n \"import\": {\n \"types\": \"./dist/pagination.d.ts\",\n \"default\": \"./dist/features/pagination/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/pagination.d.cts\",\n \"default\": \"./dist/features/pagination/index.cjs\"\n }\n },\n \"./messages\": {\n \"import\": {\n \"types\": \"./dist/messages.d.ts\",\n \"default\": \"./dist/messages/index.js\"\n },\n \"require\": {\n \"types\": \"./dist/messages.d.cts\",\n \"default\": \"./dist/messages/index.cjs\"\n }\n },\n \"./schema\": {\n \"import\": {\n \"types\": \"./dist/schema.d.ts\",\n \"default\": \"./dist/ingest/schema-entry.js\"\n },\n \"require\": {\n \"types\": \"./dist/schema.d.cts\",\n \"default\": \"./dist/ingest/schema-entry.cjs\"\n }\n },\n \"./search-async\": {\n \"import\": {\n \"types\": \"./dist/search-async.d.ts\",\n \"default\": \"./dist/features/search/search-async-entry.js\"\n },\n \"require\": {\n \"types\": \"./dist/search-async.d.cts\",\n \"default\": \"./dist/features/search/search-async-entry.cjs\"\n }\n },\n \"./server\": {\n \"import\": {\n \"types\": \"./dist/server.d.ts\",\n \"default\": \"./dist/source/server-entry.js\"\n },\n \"require\": {\n \"types\": \"./dist/server.d.cts\",\n \"default\": \"./dist/source/server-entry.cjs\"\n }\n },\n \"./package.json\": \"./package.json\"\n },\n \"files\": [\n \"dist\"\n ],\n \"scripts\": {\n \"build\": \"tsup && node scripts/postbuild.mjs\",\n \"dev\": \"tsup --watch\",\n \"typecheck\": \"tsc -p tsconfig.json\",\n \"check:pkg\": \"publint --strict && attw --pack . && node scripts/check-catalog.mjs\",\n \"check:catalog\": \"node scripts/check-catalog.mjs\"\n },\n \"dependencies\": {\n \"ex-search\": \"1.1.1\",\n \"exsorted\": \"1.2.3\",\n \"kk-debounce\": \"1.1.0\"\n },\n \"devDependencies\": {\n \"esbuild\": \"0.27.7\"\n }\n}\n","// Read from package.json at build time (the bundler inlines the one field), so a release never\n// ships a stale hard-coded version.\nimport { version } from '../package.json'\n\n/** The `@datakable/core` version (`context.package`, docs URLs, the global version registry). */\nexport const VERSION: string = version\n"],"mappings":";AAEE,cAAW;;;ACGN,IAAM,UAAkB;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/ingest/test-schemas.ts
|
|
21
|
-
var test_schemas_exports = {};
|
|
22
|
-
__export(test_schemas_exports, {
|
|
23
|
-
makeSchema: () => makeSchema,
|
|
24
|
-
userCheck: () => userCheck,
|
|
25
|
-
userSchema: () => userSchema
|
|
26
|
-
});
|
|
27
|
-
module.exports = __toCommonJS(test_schemas_exports);
|
|
28
|
-
function makeSchema(check, opts = {}) {
|
|
29
|
-
const delay = opts.async;
|
|
30
|
-
return {
|
|
31
|
-
"~standard": {
|
|
32
|
-
version: 1,
|
|
33
|
-
vendor: opts.vendor ?? "test",
|
|
34
|
-
validate: (value) => {
|
|
35
|
-
if (!delay) return check(value);
|
|
36
|
-
const wait = typeof delay === "function" ? delay() : Promise.resolve();
|
|
37
|
-
return wait.then(() => check(value));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function userCheck(value) {
|
|
43
|
-
if (typeof value !== "object" || value === null) {
|
|
44
|
-
return { issues: [{ message: `Expected object, received ${JSON.stringify(value)}` }] };
|
|
45
|
-
}
|
|
46
|
-
const v = value;
|
|
47
|
-
const issues = [];
|
|
48
|
-
if (typeof v.id !== "number") {
|
|
49
|
-
issues.push({ message: `Expected number, received ${JSON.stringify(v.id)}`, path: ["id"] });
|
|
50
|
-
}
|
|
51
|
-
if (typeof v.name !== "string") {
|
|
52
|
-
issues.push({ message: `Expected string, received ${JSON.stringify(v.name)}`, path: ["name"] });
|
|
53
|
-
}
|
|
54
|
-
const age = typeof v.age === "string" && /^\d+$/.test(v.age) ? Number(v.age) : v.age;
|
|
55
|
-
if (typeof age !== "number") {
|
|
56
|
-
issues.push({
|
|
57
|
-
message: `Expected number, received ${JSON.stringify(v.age)}`,
|
|
58
|
-
path: [{ key: "age" }]
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
if (issues.length > 0) return { issues };
|
|
62
|
-
return { value: { id: v.id, name: v.name, age } };
|
|
63
|
-
}
|
|
64
|
-
var userSchema = makeSchema(
|
|
65
|
-
userCheck
|
|
66
|
-
);
|
|
67
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
68
|
-
0 && (module.exports = {
|
|
69
|
-
makeSchema,
|
|
70
|
-
userCheck,
|
|
71
|
-
userSchema
|
|
72
|
-
});
|
|
73
|
-
//# sourceMappingURL=test-schemas.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ingest/test-schemas.ts"],"sourcesContent":["import type { StandardSchemaV1 } from './standard-schema'\n\n/** Test-only Standard Schema implementations (no schema library is a dependency, §5.1). */\n\ntype Check<Out> = (value: unknown) => StandardSchemaV1.Result<Out>\n\n/** A conforming schema from a check; `async` makes `validate` return a promise. */\nexport function makeSchema<Out, In = unknown>(\n check: Check<Out>,\n opts: { async?: boolean | (() => Promise<void>); vendor?: string } = {},\n): StandardSchemaV1<In, Out> {\n const delay = opts.async\n return {\n '~standard': {\n version: 1,\n vendor: opts.vendor ?? 'test',\n validate: (value) => {\n if (!delay) return check(value)\n const wait = typeof delay === 'function' ? delay() : Promise.resolve()\n return wait.then(() => check(value))\n },\n },\n }\n}\n\nexport type User = { id: number; name: string; age: number }\n\n/**\n * `{ id: number, name: string, age: number | numeric string }`; `age` is coerced to a number.\n * Messages embed the received value, like real validators do (redaction must scrub them).\n */\nexport function userCheck(value: unknown): StandardSchemaV1.Result<User> {\n if (typeof value !== 'object' || value === null) {\n return { issues: [{ message: `Expected object, received ${JSON.stringify(value)}` }] }\n }\n const v = value as Record<string, unknown>\n const issues: StandardSchemaV1.Issue[] = []\n if (typeof v.id !== 'number') {\n issues.push({ message: `Expected number, received ${JSON.stringify(v.id)}`, path: ['id'] })\n }\n if (typeof v.name !== 'string') {\n issues.push({ message: `Expected string, received ${JSON.stringify(v.name)}`, path: ['name'] })\n }\n const age = typeof v.age === 'string' && /^\\d+$/.test(v.age) ? Number(v.age) : v.age\n if (typeof age !== 'number') {\n issues.push({\n message: `Expected number, received ${JSON.stringify(v.age)}`,\n path: [{ key: 'age' }],\n })\n }\n if (issues.length > 0) return { issues }\n return { value: { id: v.id as number, name: v.name as string, age: age as number } }\n}\n\nexport const userSchema = makeSchema<User, { id: number; name: string; age: number | string }>(\n userCheck,\n)\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOO,SAAS,WACd,OACA,OAAqE,CAAC,GAC3C;AAC3B,QAAM,QAAQ,KAAK;AACnB,SAAO;AAAA,IACL,aAAa;AAAA,MACX,SAAS;AAAA,MACT,QAAQ,KAAK,UAAU;AAAA,MACvB,UAAU,CAAC,UAAU;AACnB,YAAI,CAAC,MAAO,QAAO,MAAM,KAAK;AAC9B,cAAM,OAAO,OAAO,UAAU,aAAa,MAAM,IAAI,QAAQ,QAAQ;AACrE,eAAO,KAAK,KAAK,MAAM,MAAM,KAAK,CAAC;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACF;AAQO,SAAS,UAAU,OAA+C;AACvE,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,6BAA6B,KAAK,UAAU,KAAK,CAAC,GAAG,CAAC,EAAE;AAAA,EACvF;AACA,QAAM,IAAI;AACV,QAAM,SAAmC,CAAC;AAC1C,MAAI,OAAO,EAAE,OAAO,UAAU;AAC5B,WAAO,KAAK,EAAE,SAAS,6BAA6B,KAAK,UAAU,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;AAAA,EAC5F;AACA,MAAI,OAAO,EAAE,SAAS,UAAU;AAC9B,WAAO,KAAK,EAAE,SAAS,6BAA6B,KAAK,UAAU,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;AAAA,EAChG;AACA,QAAM,MAAM,OAAO,EAAE,QAAQ,YAAY,QAAQ,KAAK,EAAE,GAAG,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE;AACjF,MAAI,OAAO,QAAQ,UAAU;AAC3B,WAAO,KAAK;AAAA,MACV,SAAS,6BAA6B,KAAK,UAAU,EAAE,GAAG,CAAC;AAAA,MAC3D,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC;AAAA,IACvB,CAAC;AAAA,EACH;AACA,MAAI,OAAO,SAAS,EAAG,QAAO,EAAE,OAAO;AACvC,SAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAc,MAAM,EAAE,MAAgB,IAAmB,EAAE;AACrF;AAEO,IAAM,aAAa;AAAA,EACxB;AACF;","names":[]}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// src/ingest/test-schemas.ts
|
|
2
|
-
function makeSchema(check, opts = {}) {
|
|
3
|
-
const delay = opts.async;
|
|
4
|
-
return {
|
|
5
|
-
"~standard": {
|
|
6
|
-
version: 1,
|
|
7
|
-
vendor: opts.vendor ?? "test",
|
|
8
|
-
validate: (value) => {
|
|
9
|
-
if (!delay) return check(value);
|
|
10
|
-
const wait = typeof delay === "function" ? delay() : Promise.resolve();
|
|
11
|
-
return wait.then(() => check(value));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function userCheck(value) {
|
|
17
|
-
if (typeof value !== "object" || value === null) {
|
|
18
|
-
return { issues: [{ message: `Expected object, received ${JSON.stringify(value)}` }] };
|
|
19
|
-
}
|
|
20
|
-
const v = value;
|
|
21
|
-
const issues = [];
|
|
22
|
-
if (typeof v.id !== "number") {
|
|
23
|
-
issues.push({ message: `Expected number, received ${JSON.stringify(v.id)}`, path: ["id"] });
|
|
24
|
-
}
|
|
25
|
-
if (typeof v.name !== "string") {
|
|
26
|
-
issues.push({ message: `Expected string, received ${JSON.stringify(v.name)}`, path: ["name"] });
|
|
27
|
-
}
|
|
28
|
-
const age = typeof v.age === "string" && /^\d+$/.test(v.age) ? Number(v.age) : v.age;
|
|
29
|
-
if (typeof age !== "number") {
|
|
30
|
-
issues.push({
|
|
31
|
-
message: `Expected number, received ${JSON.stringify(v.age)}`,
|
|
32
|
-
path: [{ key: "age" }]
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
if (issues.length > 0) return { issues };
|
|
36
|
-
return { value: { id: v.id, name: v.name, age } };
|
|
37
|
-
}
|
|
38
|
-
var userSchema = makeSchema(
|
|
39
|
-
userCheck
|
|
40
|
-
);
|
|
41
|
-
export {
|
|
42
|
-
makeSchema,
|
|
43
|
-
userCheck,
|
|
44
|
-
userSchema
|
|
45
|
-
};
|
|
46
|
-
//# sourceMappingURL=test-schemas.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ingest/test-schemas.ts"],"sourcesContent":["import type { StandardSchemaV1 } from './standard-schema'\n\n/** Test-only Standard Schema implementations (no schema library is a dependency, §5.1). */\n\ntype Check<Out> = (value: unknown) => StandardSchemaV1.Result<Out>\n\n/** A conforming schema from a check; `async` makes `validate` return a promise. */\nexport function makeSchema<Out, In = unknown>(\n check: Check<Out>,\n opts: { async?: boolean | (() => Promise<void>); vendor?: string } = {},\n): StandardSchemaV1<In, Out> {\n const delay = opts.async\n return {\n '~standard': {\n version: 1,\n vendor: opts.vendor ?? 'test',\n validate: (value) => {\n if (!delay) return check(value)\n const wait = typeof delay === 'function' ? delay() : Promise.resolve()\n return wait.then(() => check(value))\n },\n },\n }\n}\n\nexport type User = { id: number; name: string; age: number }\n\n/**\n * `{ id: number, name: string, age: number | numeric string }`; `age` is coerced to a number.\n * Messages embed the received value, like real validators do (redaction must scrub them).\n */\nexport function userCheck(value: unknown): StandardSchemaV1.Result<User> {\n if (typeof value !== 'object' || value === null) {\n return { issues: [{ message: `Expected object, received ${JSON.stringify(value)}` }] }\n }\n const v = value as Record<string, unknown>\n const issues: StandardSchemaV1.Issue[] = []\n if (typeof v.id !== 'number') {\n issues.push({ message: `Expected number, received ${JSON.stringify(v.id)}`, path: ['id'] })\n }\n if (typeof v.name !== 'string') {\n issues.push({ message: `Expected string, received ${JSON.stringify(v.name)}`, path: ['name'] })\n }\n const age = typeof v.age === 'string' && /^\\d+$/.test(v.age) ? Number(v.age) : v.age\n if (typeof age !== 'number') {\n issues.push({\n message: `Expected number, received ${JSON.stringify(v.age)}`,\n path: [{ key: 'age' }],\n })\n }\n if (issues.length > 0) return { issues }\n return { value: { id: v.id as number, name: v.name as string, age: age as number } }\n}\n\nexport const userSchema = makeSchema<User, { id: number; name: string; age: number | string }>(\n userCheck,\n)\n"],"mappings":";AAOO,SAAS,WACd,OACA,OAAqE,CAAC,GAC3C;AAC3B,QAAM,QAAQ,KAAK;AACnB,SAAO;AAAA,IACL,aAAa;AAAA,MACX,SAAS;AAAA,MACT,QAAQ,KAAK,UAAU;AAAA,MACvB,UAAU,CAAC,UAAU;AACnB,YAAI,CAAC,MAAO,QAAO,MAAM,KAAK;AAC9B,cAAM,OAAO,OAAO,UAAU,aAAa,MAAM,IAAI,QAAQ,QAAQ;AACrE,eAAO,KAAK,KAAK,MAAM,MAAM,KAAK,CAAC;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AACF;AAQO,SAAS,UAAU,OAA+C;AACvE,MAAI,OAAO,UAAU,YAAY,UAAU,MAAM;AAC/C,WAAO,EAAE,QAAQ,CAAC,EAAE,SAAS,6BAA6B,KAAK,UAAU,KAAK,CAAC,GAAG,CAAC,EAAE;AAAA,EACvF;AACA,QAAM,IAAI;AACV,QAAM,SAAmC,CAAC;AAC1C,MAAI,OAAO,EAAE,OAAO,UAAU;AAC5B,WAAO,KAAK,EAAE,SAAS,6BAA6B,KAAK,UAAU,EAAE,EAAE,CAAC,IAAI,MAAM,CAAC,IAAI,EAAE,CAAC;AAAA,EAC5F;AACA,MAAI,OAAO,EAAE,SAAS,UAAU;AAC9B,WAAO,KAAK,EAAE,SAAS,6BAA6B,KAAK,UAAU,EAAE,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC;AAAA,EAChG;AACA,QAAM,MAAM,OAAO,EAAE,QAAQ,YAAY,QAAQ,KAAK,EAAE,GAAG,IAAI,OAAO,EAAE,GAAG,IAAI,EAAE;AACjF,MAAI,OAAO,QAAQ,UAAU;AAC3B,WAAO,KAAK;AAAA,MACV,SAAS,6BAA6B,KAAK,UAAU,EAAE,GAAG,CAAC;AAAA,MAC3D,MAAM,CAAC,EAAE,KAAK,MAAM,CAAC;AAAA,IACvB,CAAC;AAAA,EACH;AACA,MAAI,OAAO,SAAS,EAAG,QAAO,EAAE,OAAO;AACvC,SAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAc,MAAM,EAAE,MAAgB,IAAmB,EAAE;AACrF;AAEO,IAAM,aAAa;AAAA,EACxB;AACF;","names":[]}
|