ata-validator 1.0.1 → 1.1.0
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/CHANGELOG.md +22 -0
- package/README.md +19 -2
- package/index.js +69 -18
- package/lib/aot.js +1 -1
- package/lib/js-compiler.js +37 -0
- package/lib/native-load.browser.js +1 -1
- package/lib/native-load.js +83 -11
- package/lib/t.js +90 -0
- package/lib/version.js +3 -3
- package/package.json +14 -20
- package/t.d.ts +84 -0
- package/CMakeLists.txt +0 -150
- package/binding/ata_napi.cpp +0 -1574
- package/binding-options.js +0 -4
- package/deps/simdjson/simdjson.cpp +0 -56221
- package/deps/simdjson/simdjson.h +0 -122784
- package/include/ata.h +0 -111
- package/include/ata_c.h +0 -57
- package/prebuilds/ata-darwin-arm64/node-napi-v10.node +0 -0
- package/prebuilds/ata-linux-arm64/node-napi-v10.node +0 -0
- package/prebuilds/ata-linux-arm64-musl/node-napi-v10.node +0 -0
- package/prebuilds/ata-linux-x64/node-napi-v10.node +0 -0
- package/prebuilds/ata-linux-x64-musl/node-napi-v10.node +0 -0
- package/prebuilds/ata-win32-x64/node-napi-v10.node +0 -0
- package/scripts/check-doc-coverage.js +0 -34
- package/scripts/check-prebuilds.js +0 -54
- package/scripts/install.js +0 -23
- package/scripts/regen-error-codes-doc.js +0 -40
- package/scripts/regen-lock.js +0 -19
- package/scripts/regen-safe-regex-source.js +0 -33
- package/src/ata.cpp +0 -3146
- package/src/ata_c.cpp +0 -63
package/t.d.ts
CHANGED
|
@@ -167,6 +167,72 @@ export interface TRef extends JSONSchema { $ref: string }
|
|
|
167
167
|
export interface TAny extends JSONSchema {}
|
|
168
168
|
export interface TNever extends JSONSchema { not: {} }
|
|
169
169
|
|
|
170
|
+
/** Any object schema the modifier combinators accept. */
|
|
171
|
+
export interface TObjectLike extends JSONSchema {
|
|
172
|
+
type: 'object';
|
|
173
|
+
properties: Record<string, JSONSchema>;
|
|
174
|
+
required?: ReadonlyArray<string>;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
type ReqUnion<S> = S extends { required: ReadonlyArray<infer R> } ? R : never;
|
|
178
|
+
|
|
179
|
+
export interface TPick<S extends TObjectLike, K extends ReadonlyArray<string>> extends JSONSchema {
|
|
180
|
+
type: 'object';
|
|
181
|
+
properties: { [P in Extract<keyof S['properties'], K[number]>]: S['properties'][P] };
|
|
182
|
+
required: ReadonlyArray<Extract<ReqUnion<S>, K[number]>>;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export interface TOmit<S extends TObjectLike, K extends ReadonlyArray<string>> extends JSONSchema {
|
|
186
|
+
type: 'object';
|
|
187
|
+
properties: { [P in Exclude<Extract<keyof S['properties'], string>, K[number]>]: S['properties'][P] };
|
|
188
|
+
required: ReadonlyArray<Exclude<Extract<ReqUnion<S>, string>, K[number]>>;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
export interface TPartial<S extends TObjectLike> extends JSONSchema {
|
|
192
|
+
type: 'object';
|
|
193
|
+
properties: S['properties'];
|
|
194
|
+
required: ReadonlyArray<never>;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
export interface TRequiredAll<S extends TObjectLike> extends JSONSchema {
|
|
198
|
+
type: 'object';
|
|
199
|
+
properties: S['properties'];
|
|
200
|
+
required: ReadonlyArray<Extract<keyof S['properties'], string>>;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
export interface TRequiredWith<S extends TObjectLike, K extends ReadonlyArray<string>> extends JSONSchema {
|
|
204
|
+
type: 'object';
|
|
205
|
+
properties: S['properties'];
|
|
206
|
+
required: ReadonlyArray<Extract<ReqUnion<S> | K[number], Extract<keyof S['properties'], string>>>;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
type MergeProps<A, B> = { [K in Extract<keyof A | keyof B, string>]: K extends keyof B ? B[K] : K extends keyof A ? A[K] : never };
|
|
210
|
+
|
|
211
|
+
type CompositeProps<S extends ReadonlyArray<TObjectLike>> =
|
|
212
|
+
S extends readonly [] ? {} :
|
|
213
|
+
S extends readonly [infer H extends TObjectLike, ...infer R extends ReadonlyArray<TObjectLike>]
|
|
214
|
+
? MergeProps<H['properties'], CompositeProps<R>>
|
|
215
|
+
: Record<string, JSONSchema>;
|
|
216
|
+
|
|
217
|
+
type CompositeReq<S extends ReadonlyArray<TObjectLike>> =
|
|
218
|
+
S extends readonly [] ? never :
|
|
219
|
+
S extends readonly [infer H extends TObjectLike, ...infer R extends ReadonlyArray<TObjectLike>]
|
|
220
|
+
? ReqUnion<H> | CompositeReq<R>
|
|
221
|
+
: never;
|
|
222
|
+
|
|
223
|
+
export interface TComposite<S extends ReadonlyArray<TObjectLike>> extends JSONSchema {
|
|
224
|
+
type: 'object';
|
|
225
|
+
properties: CompositeProps<S>;
|
|
226
|
+
required: ReadonlyArray<Extract<CompositeReq<S>, string>>;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface TSelf extends JSONSchema { $ref: '#/$defs/self' }
|
|
230
|
+
|
|
231
|
+
export interface TRecursive<S extends JSONSchema> extends JSONSchema {
|
|
232
|
+
$ref: '#/$defs/self';
|
|
233
|
+
$defs: { self: S };
|
|
234
|
+
}
|
|
235
|
+
|
|
170
236
|
export interface TBuilder {
|
|
171
237
|
string(opts?: StringOptions): TString;
|
|
172
238
|
number(opts?: NumericOptions): TNumber;
|
|
@@ -189,6 +255,24 @@ export interface TBuilder {
|
|
|
189
255
|
intersect<const S extends ReadonlyArray<JSONSchema>>(schemas: S): TIntersect<S>;
|
|
190
256
|
ref(pointer: string): TRef;
|
|
191
257
|
|
|
258
|
+
pick<const S extends TObjectLike, const K extends ReadonlyArray<Extract<keyof S['properties'], string>>>(schema: S, keys: K): TPick<S, K>;
|
|
259
|
+
omit<const S extends TObjectLike, const K extends ReadonlyArray<Extract<keyof S['properties'], string>>>(schema: S, keys: K): TOmit<S, K>;
|
|
260
|
+
|
|
261
|
+
partial<const S extends TObjectLike>(schema: S): TPartial<S>;
|
|
262
|
+
required<const S extends TObjectLike>(schema: S): TRequiredAll<S>;
|
|
263
|
+
required<const S extends TObjectLike, const K extends ReadonlyArray<Extract<keyof S['properties'], string>>>(schema: S, keys: K): TRequiredWith<S, K>;
|
|
264
|
+
|
|
265
|
+
composite<const S extends ReadonlyArray<TObjectLike>>(schemas: S, opts?: ObjectOptions): TComposite<S>;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Build a recursive (self-referential) schema. The `self` argument passed to
|
|
269
|
+
* `build` is a `$ref` pointing to `#/$defs/self`, and the emitted schema
|
|
270
|
+
* routes through the interpreted engine at runtime. Nesting `t.recursive`
|
|
271
|
+
* inside itself is unsupported: both layers would claim `#/$defs/self` and
|
|
272
|
+
* the inner definition would silently overwrite the outer one.
|
|
273
|
+
*/
|
|
274
|
+
recursive<S extends JSONSchema>(build: (self: TSelf) => S, opts?: { title?: string; description?: string }): TRecursive<S>;
|
|
275
|
+
|
|
192
276
|
any(): TAny;
|
|
193
277
|
unknown(): TAny;
|
|
194
278
|
never(): TNever;
|
package/CMakeLists.txt
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
cmake_minimum_required(VERSION 3.28)
|
|
2
|
-
cmake_policy(SET CMP0091 NEW)
|
|
3
|
-
cmake_policy(SET CMP0042 NEW)
|
|
4
|
-
|
|
5
|
-
project(ata VERSION 0.1.0 LANGUAGES CXX)
|
|
6
|
-
|
|
7
|
-
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
|
|
8
|
-
|
|
9
|
-
set(CMAKE_CXX_STANDARD 20)
|
|
10
|
-
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
11
|
-
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
12
|
-
|
|
13
|
-
if(MSVC)
|
|
14
|
-
set(ABSL_MSVC_STATIC_RUNTIME ON)
|
|
15
|
-
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>" CACHE STRING "" FORCE)
|
|
16
|
-
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
17
|
-
endif()
|
|
18
|
-
|
|
19
|
-
option(ATA_TESTING "Build test suite" ON)
|
|
20
|
-
option(ATA_BENCHMARKS "Build benchmarks" OFF)
|
|
21
|
-
option(ATA_SANITIZE "Enable address sanitizer" OFF)
|
|
22
|
-
option(ATA_NO_RE2 "Build without RE2 regex engine (disables pattern keyword)" OFF)
|
|
23
|
-
|
|
24
|
-
# Fetch simdjson
|
|
25
|
-
include(FetchContent)
|
|
26
|
-
FetchContent_Declare(
|
|
27
|
-
simdjson
|
|
28
|
-
GIT_REPOSITORY https://github.com/simdjson/simdjson.git
|
|
29
|
-
GIT_TAG v4.5.0
|
|
30
|
-
GIT_SHALLOW TRUE
|
|
31
|
-
)
|
|
32
|
-
|
|
33
|
-
if(NOT ATA_NO_RE2)
|
|
34
|
-
# RE2 — fast regex engine (replaces std::regex)
|
|
35
|
-
set(RE2_BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
|
36
|
-
FetchContent_Declare(
|
|
37
|
-
re2
|
|
38
|
-
GIT_REPOSITORY https://github.com/google/re2.git
|
|
39
|
-
GIT_TAG 2024-07-02
|
|
40
|
-
GIT_SHALLOW TRUE
|
|
41
|
-
EXCLUDE_FROM_ALL
|
|
42
|
-
)
|
|
43
|
-
|
|
44
|
-
# Abseil — required by RE2
|
|
45
|
-
set(ABSL_PROPAGATE_CXX_STD ON CACHE BOOL "" FORCE)
|
|
46
|
-
set(ABSL_BUILD_TESTING OFF CACHE BOOL "" FORCE)
|
|
47
|
-
set(ABSL_ENABLE_INSTALL ON CACHE BOOL "" FORCE)
|
|
48
|
-
FetchContent_Declare(
|
|
49
|
-
abseil-cpp
|
|
50
|
-
GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git
|
|
51
|
-
GIT_TAG 20240722.0
|
|
52
|
-
GIT_SHALLOW TRUE
|
|
53
|
-
)
|
|
54
|
-
|
|
55
|
-
FetchContent_MakeAvailable(abseil-cpp simdjson re2)
|
|
56
|
-
else()
|
|
57
|
-
FetchContent_MakeAvailable(simdjson)
|
|
58
|
-
endif()
|
|
59
|
-
|
|
60
|
-
if (CMAKE_JS_VERSION)
|
|
61
|
-
# add_definitions(-DNAPI_VERSION=10)
|
|
62
|
-
include_directories(${CMAKE_JS_INC})
|
|
63
|
-
file(GLOB SOURCE_FILES "binding/*.cpp" "src/*.cpp")
|
|
64
|
-
else()
|
|
65
|
-
file(GLOB SOURCE_FILES "src/*.cpp")
|
|
66
|
-
endif()
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
if (CMAKE_JS_VERSION)
|
|
70
|
-
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
|
|
71
|
-
|
|
72
|
-
# Include Node-API wrappers
|
|
73
|
-
execute_process(
|
|
74
|
-
COMMAND node -p "require('node-addon-api').include"
|
|
75
|
-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
76
|
-
OUTPUT_VARIABLE NODE_ADDON_API_DIR
|
|
77
|
-
)
|
|
78
|
-
|
|
79
|
-
string(REGEX REPLACE "[\r\n\"]" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
|
|
80
|
-
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR})
|
|
81
|
-
|
|
82
|
-
# Include Node-API C headers
|
|
83
|
-
execute_process(
|
|
84
|
-
COMMAND node -p "require('node-api-headers').include_dir"
|
|
85
|
-
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
86
|
-
OUTPUT_VARIABLE NODE_API_HEADERS_DIR
|
|
87
|
-
)
|
|
88
|
-
|
|
89
|
-
string(REGEX REPLACE "[\r\n\"]" "" NODE_API_HEADERS_DIR ${NODE_API_HEADERS_DIR})
|
|
90
|
-
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_API_HEADERS_DIR})
|
|
91
|
-
else()
|
|
92
|
-
add_library(${PROJECT_NAME} ${SOURCE_FILES})
|
|
93
|
-
endif()
|
|
94
|
-
|
|
95
|
-
target_include_directories(${PROJECT_NAME} PUBLIC include)
|
|
96
|
-
if(ATA_NO_RE2)
|
|
97
|
-
target_link_libraries(${PROJECT_NAME} PRIVATE simdjson)
|
|
98
|
-
target_compile_definitions(${PROJECT_NAME} PRIVATE ATA_NO_RE2)
|
|
99
|
-
else()
|
|
100
|
-
target_link_libraries(${PROJECT_NAME} PRIVATE simdjson re2)
|
|
101
|
-
endif()
|
|
102
|
-
|
|
103
|
-
if (CMAKE_JS_VERSION)
|
|
104
|
-
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_JS_INC})
|
|
105
|
-
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_JS_LIB})
|
|
106
|
-
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
|
|
107
|
-
endif()
|
|
108
|
-
|
|
109
|
-
add_library(ata::ata ALIAS ata)
|
|
110
|
-
|
|
111
|
-
if(CMAKE_JS_VERSION AND UNIX AND NOT APPLE)
|
|
112
|
-
target_compile_options(${PROJECT_NAME} PRIVATE -fvisibility=hidden -fvisibility-inlines-hidden)
|
|
113
|
-
target_link_options(${PROJECT_NAME} PRIVATE -Wl,--exclude-libs,ALL)
|
|
114
|
-
endif()
|
|
115
|
-
|
|
116
|
-
if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)
|
|
117
|
-
# Generate node.lib
|
|
118
|
-
execute_process(COMMAND ${CMAKE_AR} /def:${CMAKE_JS_NODELIB_DEF} /out:${CMAKE_JS_NODELIB_TARGET} ${CMAKE_STATIC_LINKER_FLAGS})
|
|
119
|
-
endif()
|
|
120
|
-
|
|
121
|
-
if(ATA_SANITIZE)
|
|
122
|
-
target_compile_options(ata PRIVATE -fsanitize=address -fno-omit-frame-pointer)
|
|
123
|
-
target_link_options(ata PRIVATE -fsanitize=address)
|
|
124
|
-
endif()
|
|
125
|
-
|
|
126
|
-
# Tests
|
|
127
|
-
if(ATA_TESTING)
|
|
128
|
-
enable_testing()
|
|
129
|
-
add_executable(ata_tests tests/test.cpp)
|
|
130
|
-
target_link_libraries(ata_tests PRIVATE ata simdjson)
|
|
131
|
-
if(ATA_SANITIZE)
|
|
132
|
-
target_compile_options(ata_tests PRIVATE -fsanitize=address -fno-omit-frame-pointer)
|
|
133
|
-
target_link_options(ata_tests PRIVATE -fsanitize=address)
|
|
134
|
-
endif()
|
|
135
|
-
add_test(NAME ata_tests COMMAND ata_tests)
|
|
136
|
-
endif()
|
|
137
|
-
|
|
138
|
-
# Benchmarks
|
|
139
|
-
if(ATA_BENCHMARKS)
|
|
140
|
-
add_executable(ata_bench benchmark/bench.cpp)
|
|
141
|
-
target_link_libraries(ata_bench PRIVATE ata simdjson)
|
|
142
|
-
endif()
|
|
143
|
-
|
|
144
|
-
# Fuzz targets (for OSS-Fuzz / libFuzzer)
|
|
145
|
-
if(ATA_FUZZING)
|
|
146
|
-
foreach(fuzzer compile_fuzzer validate_fuzzer roundtrip_fuzzer)
|
|
147
|
-
add_executable(${fuzzer} fuzz/${fuzzer}.cpp)
|
|
148
|
-
target_link_libraries(${fuzzer} PRIVATE ata simdjson ${LIB_FUZZING_ENGINE})
|
|
149
|
-
endforeach()
|
|
150
|
-
endif()
|