@kaapi/validator-arktype 0.0.32 → 0.0.34

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.
Files changed (32) hide show
  1. package/lib/{chunk-ML2GHWVG.js → chunk-QLKH743P.js} +74 -2
  2. package/lib/chunk-QLKH743P.js.map +1 -0
  3. package/lib/{chunk-4FGTS4GA.js → chunk-U7WK3Q5P.js} +4 -4
  4. package/lib/chunk-U7WK3Q5P.js.map +1 -0
  5. package/lib/doc-helpers.d.ts +2 -0
  6. package/lib/doc-helpers.js +1 -1
  7. package/lib/index.js +2 -2
  8. package/lib/metafile-esm.json +1 -1
  9. package/lib/validator.js +2 -2
  10. package/package.json +3 -3
  11. package/coverage/lcov-report/base.css +0 -224
  12. package/coverage/lcov-report/block-navigation.js +0 -87
  13. package/coverage/lcov-report/favicon.png +0 -0
  14. package/coverage/lcov-report/index.html +0 -146
  15. package/coverage/lcov-report/prettify.css +0 -1
  16. package/coverage/lcov-report/prettify.js +0 -2
  17. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  18. package/coverage/lcov-report/sorter.js +0 -210
  19. package/coverage/lcov-report/validator-arktype/index.html +0 -116
  20. package/coverage/lcov-report/validator-arktype/lib/chunk-55J6XMHW.js.html +0 -85
  21. package/coverage/lcov-report/validator-arktype/lib/index.html +0 -131
  22. package/coverage/lcov-report/validator-arktype/lib/index.js.html +0 -130
  23. package/coverage/lcov-report/validator-arktype/package.json.html +0 -244
  24. package/coverage/lcov-report/validator-arktype/src/doc-helpers.ts.html +0 -625
  25. package/coverage/lcov-report/validator-arktype/src/index.html +0 -131
  26. package/coverage/lcov-report/validator-arktype/src/validator.ts.html +0 -628
  27. package/coverage/lcov.info +0 -605
  28. package/coverage/tmp/coverage-21912-1762725516454-0.json +0 -1
  29. package/coverage/tmp/coverage-3604-1762725523461-1.json +0 -1
  30. package/coverage/tmp/coverage-3604-1762725523645-0.json +0 -1
  31. package/lib/chunk-4FGTS4GA.js.map +0 -1
  32. package/lib/chunk-ML2GHWVG.js.map +0 -1
@@ -1,6 +1,50 @@
1
1
  // src/doc-helpers.ts
2
2
  import { OpenAPIJsonHelper, PostmanJsonHelper } from "@novice1/api-doc-json-helper";
3
3
  import { type, Type } from "arktype";
4
+ function reformatAnyOf(schema) {
5
+ if ("anyOf" in schema) {
6
+ const propertiesToCheck = [];
7
+ if (!schema.description) {
8
+ propertiesToCheck.push("description");
9
+ }
10
+ if (!schema.examples) {
11
+ propertiesToCheck.push("examples");
12
+ }
13
+ if (!schema.format) {
14
+ propertiesToCheck.push("format");
15
+ }
16
+ const objects = schema.anyOf;
17
+ for (const prop of propertiesToCheck) {
18
+ const firstElement = objects[0];
19
+ if (firstElement && typeof firstElement === "object") {
20
+ const firstValue = firstElement[prop];
21
+ const arraysEqual = (a, b) => {
22
+ if (!Array.isArray(a) || !Array.isArray(b)) return false;
23
+ if (a.length !== b.length) return false;
24
+ const sortedA = [...a].sort();
25
+ const sortedB = [...b].sort();
26
+ return sortedA.every((val, i) => val === sortedB[i]);
27
+ };
28
+ const allSame = objects.every((obj) => {
29
+ const val = obj[prop];
30
+ if (Array.isArray(firstValue) && Array.isArray(val)) {
31
+ return arraysEqual(firstValue, val);
32
+ }
33
+ return val === firstValue;
34
+ });
35
+ if (allSame) {
36
+ if (prop === "description" && typeof firstValue === "string") {
37
+ schema.description = firstValue;
38
+ } else if (prop === "examples" && Array.isArray(firstValue)) {
39
+ schema.examples = firstValue;
40
+ } else if (prop === "format" && typeof firstValue === "string") {
41
+ schema.format = firstValue;
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
4
48
  function transformValue(value) {
5
49
  let r = value;
6
50
  if (value && typeof value === "function" && "toJsonSchema" in value && typeof value.toJsonSchema === "function") {
@@ -30,6 +74,21 @@ function transformValue(value) {
30
74
  }
31
75
  }
32
76
  }
77
+ if ("properties" in r2) {
78
+ const r22 = value.toJSON();
79
+ if ("in" in r22 && r22.in && typeof r22.in === "object" && "optional" in r22.in) {
80
+ if (Array.isArray(r22.in.optional)) {
81
+ for (const prop of r22.in.optional) {
82
+ if (typeof prop === "object" && prop && "key" in prop && typeof prop.key === "string" && typeof r2.properties[prop.key].default === "undefined" && "default" in prop && typeof prop.default !== "undefined") {
83
+ r2.properties[prop.key].default = prop.default;
84
+ }
85
+ }
86
+ }
87
+ }
88
+ for (const prop in r2.properties) {
89
+ reformatAnyOf(r2.properties[prop]);
90
+ }
91
+ }
33
92
  return r2;
34
93
  }
35
94
  });
@@ -89,7 +148,7 @@ var OpenAPIArkHelper = class _OpenAPIArkHelper extends OpenAPIJsonHelper {
89
148
  let r = super.isRequired();
90
149
  if (!r && this._originalSchema) {
91
150
  const schema = this._schema;
92
- if ("required" in schema && Array.isArray(schema.required) && "properties" in schema && typeof schema.properties === "object" && schema.properties && schema.required.length === Object.keys(schema.properties).length) {
151
+ if ("required" in schema && Array.isArray(schema.required) && "properties" in schema && typeof schema.properties === "object" && schema.properties && schema.required.length <= Object.keys(schema.properties).length) {
93
152
  r = true;
94
153
  }
95
154
  }
@@ -135,10 +194,23 @@ var OpenAPIArkHelper = class _OpenAPIArkHelper extends OpenAPIJsonHelper {
135
194
  var PostmanArkHelper = class _PostmanArkHelper extends PostmanJsonHelper {
136
195
  constructor(params, isRequired) {
137
196
  super({ ...params, value: transformValue(params.value) }, isRequired);
197
+ if (params.value instanceof Type) {
198
+ this._originalSchema = params.value;
199
+ }
138
200
  }
139
201
  isValid() {
140
202
  return !!(this._schema && typeof this._schema === "object" && !("~standard" in this._schema) && ("type" in this._schema && typeof this._schema.type === "string" || "oneOf" in this._schema && Array.isArray(this._schema.oneOf) || "anyOf" in this._schema && Array.isArray(this._schema.anyOf) || "enum" in this._schema && Array.isArray(this._schema.enum)));
141
203
  }
204
+ isRequired() {
205
+ let r = super.isRequired();
206
+ if (!r && this._originalSchema) {
207
+ const schema = this._schema;
208
+ if ("required" in schema && Array.isArray(schema.required) && "properties" in schema && typeof schema.properties === "object" && schema.properties && schema.required.length <= Object.keys(schema.properties).length) {
209
+ r = true;
210
+ }
211
+ }
212
+ return r;
213
+ }
142
214
  getFirstItem() {
143
215
  const schema = this._schema;
144
216
  if ("items" in schema && typeof schema.items === "object") {
@@ -174,4 +246,4 @@ export {
174
246
  OpenAPIArkHelper,
175
247
  PostmanArkHelper
176
248
  };
177
- //# sourceMappingURL=chunk-ML2GHWVG.js.map
249
+ //# sourceMappingURL=chunk-QLKH743P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/doc-helpers.ts"],"sourcesContent":["import type { KaapiOpenAPIHelperInterface } from '@kaapi/kaapi';\nimport { OpenAPIJsonHelper, PostmanJsonHelper } from '@novice1/api-doc-json-helper';\nimport { type, Type, type JsonSchema } from 'arktype';\n\n/**\n * reformat anyOf to externalize common values for: \n * - examples\n * - format\n * - description\n */\nfunction reformatAnyOf(schema: JsonSchema) {\n if ('anyOf' in schema) {\n const propertiesToCheck: ('description' | 'examples' | 'format')[] = [];\n if (!schema.description) {\n propertiesToCheck.push('description')\n }\n if (!schema.examples) {\n propertiesToCheck.push('examples')\n }\n if (!schema.format) {\n propertiesToCheck.push('format')\n }\n const objects = schema.anyOf;\n for (const prop of propertiesToCheck) {\n // Get the value from the first object\n const firstElement = objects[0]\n if (firstElement && typeof firstElement === 'object') {\n const firstValue = firstElement[prop];\n\n // Helper to compare arrays ignoring order\n const arraysEqual = (a: unknown, b: unknown) => {\n if (!Array.isArray(a) || !Array.isArray(b)) return false;\n if (a.length !== b.length) return false;\n const sortedA = [...a].sort();\n const sortedB = [...b].sort();\n return sortedA.every((val, i) => val === sortedB[i]);\n };\n\n // Check all objects\n const allSame = objects.every(obj => {\n const val = obj[prop];\n if (Array.isArray(firstValue) && Array.isArray(val)) {\n return arraysEqual(firstValue, val);\n }\n return val === firstValue;\n });\n\n if (allSame) {\n if (prop === 'description' && typeof firstValue === 'string') {\n schema.description = firstValue;\n } else if (prop === 'examples' && Array.isArray(firstValue)) {\n schema.examples = firstValue;\n } else if (prop === 'format' && typeof firstValue === 'string') {\n schema.format = firstValue;\n }\n }\n }\n }\n }\n}\n\nfunction transformValue(value?: Type | object | unknown) {\n let r: unknown = value;\n if (value && typeof value === 'function' && 'toJsonSchema' in value && typeof value.toJsonSchema === 'function') {\n r = (value as Type).toJsonSchema({\n fallback: (v) => {\n let r: JsonSchema & { _instanceof?: string } = {};\n let _instanceof = '';\n if (v && 'proto' in v && v.proto && typeof v.proto === 'function' && 'name' in v.proto) {\n r.type = 'object';\n r._instanceof = `${v.proto.name}`;\n _instanceof = `${v.proto.name}`;\n }\n if (v.base) {\n r = { ...r, ...v.base };\n if ('out' in v && v.out) {\n if ('anyOf' in r && 'type' in v.out) {\n const description = r.anyOf[0]?.description;\n r = { ...v.out };\n if (description) {\n r.description = description;\n }\n if (_instanceof) {\n r._instanceof = _instanceof;\n }\n } else {\n r = { ...r, ...v.out };\n }\n }\n }\n\n if ('properties' in r) {\n // because default values are not always in the schema (arktype bug)\n const r2 = (value as Type).toJSON()\n if ('in' in r2 &&\n r2.in &&\n typeof r2.in === 'object' &&\n 'optional' in r2.in) {\n if (Array.isArray(r2.in.optional)) {\n for (const prop of r2.in.optional) {\n if (typeof prop === 'object' &&\n prop &&\n 'key' in prop &&\n typeof prop.key === 'string' &&\n typeof r.properties[prop.key].default === 'undefined' &&\n 'default' in prop &&\n typeof prop.default !== 'undefined'\n ) {\n r.properties[prop.key].default = prop.default\n }\n }\n }\n }\n\n // reformat anyOf schemas\n for (const prop in r.properties) {\n reformatAnyOf(r.properties[prop])\n }\n }\n return r;\n },\n });\n }\n\n return r;\n}\n\nexport class OpenAPIArkHelper extends OpenAPIJsonHelper implements KaapiOpenAPIHelperInterface {\n protected _originalSchema?: Type\n constructor(\n params: {\n value?: Type | object | unknown;\n isRoot?: boolean;\n },\n isRequired?: boolean\n ) {\n super({ ...params, value: transformValue(params.value) }, isRequired);\n if (params.value instanceof Type) {\n this._originalSchema = params.value\n }\n }\n isValid(): boolean {\n return !!(\n this._schema &&\n typeof this._schema === 'object' &&\n !('~standard' in this._schema) &&\n (('type' in this._schema && typeof this._schema.type === 'string') ||\n ('oneOf' in this._schema && Array.isArray(this._schema.oneOf)) ||\n ('anyOf' in this._schema && Array.isArray(this._schema.anyOf)) ||\n ('enum' in this._schema && Array.isArray(this._schema.enum)))\n );\n }\n getFirstItem(): OpenAPIArkHelper | undefined {\n const schema = this._schema;\n\n if ('items' in schema && typeof schema.items === 'object') {\n return new OpenAPIArkHelper({ value: schema.items });\n }\n\n return;\n }\n getChildren(): Record<string, OpenAPIArkHelper> {\n const r: Record<string, OpenAPIArkHelper> = {};\n const schema = this._schema;\n if ('properties' in schema && typeof schema.properties === 'object' && schema.properties) {\n const properties: Record<string, unknown> = schema.properties as Record<string, unknown>;\n for (const p in properties) {\n const isRequired: boolean =\n 'required' in schema && Array.isArray(schema.required) && schema.required.includes(p);\n r[p] = new OpenAPIArkHelper({ value: properties[p] }, isRequired);\n }\n }\n return r;\n }\n getAlternatives(): OpenAPIArkHelper[] {\n const r: OpenAPIArkHelper[] = [];\n const schema = this._schema;\n if ('oneOf' in schema && Array.isArray(schema.oneOf)) {\n for (const p of schema.oneOf) {\n r.push(new OpenAPIArkHelper({ value: p }));\n }\n }\n return r;\n }\n isFile(): boolean | undefined {\n if (!this.isValid()) return false;\n let r: boolean = false;\n const schema = this._schema;\n if ('properties' in schema && typeof schema.properties === 'object' && schema.properties) {\n const properties: Record<string, unknown> = schema.properties as Record<string, unknown>;\n r = !!(\n '_data' in properties &&\n properties._data &&\n typeof properties._data === 'object' &&\n '_instanceof' in properties._data &&\n properties._data._instanceof === 'Buffer'\n );\n }\n return r;\n }\n isRequired(): boolean {\n let r = super.isRequired()\n if (!r && this._originalSchema) {\n const schema = this._schema;\n // if there is at least one required property\n if ('required' in schema &&\n Array.isArray(schema.required) &&\n 'properties' in schema &&\n typeof schema.properties === 'object' &&\n schema.properties &&\n schema.required.length <= Object.keys(schema.properties).length\n ) {\n r = true\n }\n }\n return r;\n }\n getFilesChildren(): Record<string, unknown> {\n const r: Record<string, unknown> = {};\n const schema = this._schema;\n if ('properties' in schema && typeof schema.properties === 'object' && schema.properties) {\n const properties: Record<string, unknown> = schema.properties as Record<string, unknown>;\n if (this._originalSchema) {\n const betterR: Record<string, Type> = {}\n for (const p in properties) {\n const isRequired: boolean =\n 'required' in schema && Array.isArray(schema.required) && schema.required.includes(p);\n const ch = new OpenAPIArkHelper({ value: properties[p] }, isRequired);\n if (ch.isFile()) {\n const propOriginalSchema = (this._originalSchema as Type<Record<string, unknown>>)?.props?.find(v => v.key === p)\n if (propOriginalSchema) {\n let key = p;\n if (!isRequired) {\n key = `${p}?` // set it as optional\n }\n betterR[key] = propOriginalSchema.value\n }\n }\n }\n if (Object.keys(betterR).length) {\n return type<unknown, Type<typeof betterR>>(betterR) as unknown as Record<string, unknown>\n }\n } else {\n for (const p in properties) {\n const isRequired: boolean =\n 'required' in schema && Array.isArray(schema.required) && schema.required.includes(p);\n const ch = new OpenAPIArkHelper({ value: properties[p] }, isRequired);\n if (ch.isFile()) {\n r[p] = properties[p];\n }\n }\n }\n }\n return r;\n }\n}\n\nexport class PostmanArkHelper extends PostmanJsonHelper {\n protected _originalSchema?: Type\n constructor(\n params: {\n value?: Type | object | unknown;\n isRoot?: boolean;\n },\n isRequired?: boolean\n ) {\n super({ ...params, value: transformValue(params.value) }, isRequired);\n if (params.value instanceof Type) {\n this._originalSchema = params.value\n }\n }\n isValid(): boolean {\n return !!(\n this._schema &&\n typeof this._schema === 'object' &&\n !('~standard' in this._schema) &&\n (('type' in this._schema && typeof this._schema.type === 'string') ||\n ('oneOf' in this._schema && Array.isArray(this._schema.oneOf)) ||\n ('anyOf' in this._schema && Array.isArray(this._schema.anyOf)) ||\n ('enum' in this._schema && Array.isArray(this._schema.enum)))\n );\n }\n isRequired(): boolean {\n let r = super.isRequired()\n if (!r && this._originalSchema) {\n const schema = this._schema;\n // if there is at least one required property\n if ('required' in schema &&\n Array.isArray(schema.required) &&\n 'properties' in schema &&\n typeof schema.properties === 'object' &&\n schema.properties &&\n schema.required.length <= Object.keys(schema.properties).length\n ) {\n r = true\n }\n }\n return r;\n }\n getFirstItem(): PostmanArkHelper | undefined {\n const schema = this._schema;\n\n if ('items' in schema && typeof schema.items === 'object') {\n return new PostmanArkHelper({ value: schema.items });\n }\n\n return;\n }\n getChildren(): Record<string, PostmanArkHelper> {\n const r: Record<string, PostmanArkHelper> = {};\n const schema = this._schema;\n if ('properties' in schema && typeof schema.properties === 'object' && schema.properties) {\n const properties: Record<string, unknown> = schema.properties as Record<string, unknown>;\n for (const p in properties) {\n const isRequired: boolean =\n 'required' in schema && Array.isArray(schema.required) && schema.required.includes(p);\n r[p] = new PostmanArkHelper({ value: properties[p] }, isRequired);\n }\n }\n return r;\n }\n getAlternatives(): PostmanArkHelper[] {\n const r: PostmanArkHelper[] = [];\n const schema = this._schema;\n if ('oneOf' in schema && Array.isArray(schema.oneOf)) {\n for (const p of schema.oneOf) {\n r.push(new PostmanArkHelper({ value: p }));\n }\n }\n return r;\n }\n}\n"],"mappings":";AACA,SAAS,mBAAmB,yBAAyB;AACrD,SAAS,MAAM,YAA6B;AAQ5C,SAAS,cAAc,QAAoB;AACvC,MAAI,WAAW,QAAQ;AACnB,UAAM,oBAA+D,CAAC;AACtE,QAAI,CAAC,OAAO,aAAa;AACrB,wBAAkB,KAAK,aAAa;AAAA,IACxC;AACA,QAAI,CAAC,OAAO,UAAU;AAClB,wBAAkB,KAAK,UAAU;AAAA,IACrC;AACA,QAAI,CAAC,OAAO,QAAQ;AAChB,wBAAkB,KAAK,QAAQ;AAAA,IACnC;AACA,UAAM,UAAU,OAAO;AACvB,eAAW,QAAQ,mBAAmB;AAElC,YAAM,eAAe,QAAQ,CAAC;AAC9B,UAAI,gBAAgB,OAAO,iBAAiB,UAAU;AAClD,cAAM,aAAa,aAAa,IAAI;AAGpC,cAAM,cAAc,CAAC,GAAY,MAAe;AAC5C,cAAI,CAAC,MAAM,QAAQ,CAAC,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default = {
8
8
  name: "@kaapi/validator-arktype",
9
9
  type: "module",
10
- version: "0.0.32",
10
+ version: "0.0.34",
11
11
  private: false,
12
12
  description: "ArkType-powered request validation and documentation plugin for Kaapi.",
13
13
  main: "lib/index.js",
@@ -47,7 +47,7 @@ var package_default = {
47
47
  dependencies: {
48
48
  "@hapi/boom": "^10.0.1",
49
49
  "@kaapi/kaapi": "workspace:^",
50
- "@novice1/api-doc-json-helper": "^1.0.6",
50
+ "@novice1/api-doc-json-helper": "^1.0.8",
51
51
  arktype: "^2.1.25",
52
52
  tslib: "^2.8.1"
53
53
  },
@@ -189,4 +189,4 @@ export {
189
189
  supportedProps,
190
190
  validatorArk
191
191
  };
192
- //# sourceMappingURL=chunk-4FGTS4GA.js.map
192
+ //# sourceMappingURL=chunk-U7WK3Q5P.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../package.json","../src/validator.ts"],"sourcesContent":["{\n \"name\": \"@kaapi/validator-arktype\",\n \"type\": \"module\",\n \"version\": \"0.0.34\",\n \"private\": false,\n \"description\": \"ArkType-powered request validation and documentation plugin for Kaapi.\",\n \"main\": \"lib/index.js\",\n \"exports\": {\n \".\": {\n \"types\": \"./lib/index.d.ts\",\n \"default\": \"./lib/index.js\"\n }\n },\n \"scripts\": {\n \"build\": \"tsup src !src/**/*.d.ts --format esm --outDir lib --clean --metafile --dts --sourcemap && node ./scripts/buildDT.mjs\",\n \"check\": \"tsc --noEmit\",\n \"check:deps\": \"depcruise src --validate\",\n \"ci\": \"npm run verify\",\n \"coverage\": \"c8 node --loader ts-node/esm --experimental-specifier-resolution=node --no-warnings ../../node_modules/mocha/bin/mocha test/**/*.spec.ts\",\n \"format\": \"prettier --write ./\",\n \"format:check\": \"prettier --check ./\",\n \"lint\": \"eslint .\",\n \"test\": \"node --loader ts-node/esm --experimental-specifier-resolution=node --no-warnings ../../node_modules/mocha/bin/mocha test/**/*.spec.ts\",\n \"type-coverage\": \"type-coverage --at-least 90 --detail\",\n \"verify\": \"npm run lint && npm run format:check && npm run check && npm run check:deps && npm run type-coverage && npm run test:kaukau && npm run coverage\"\n },\n \"keywords\": [\n \"kaapi\",\n \"hapi\",\n \"arktype\",\n \"typescript\",\n \"validation\"\n ],\n \"author\": \"demingongo\",\n \"repository\": {\n \"type\": \"git\",\n \"url\": \"git+https://github.com/demingongo/kaapi.git\",\n \"directory\": \"packages/validator-arktype\"\n },\n \"license\": \"MIT\",\n \"dependencies\": {\n \"@hapi/boom\": \"^10.0.1\",\n \"@kaapi/kaapi\": \"workspace:^\",\n \"@novice1/api-doc-json-helper\": \"^1.0.8\",\n \"arktype\": \"^2.1.25\",\n \"tslib\": \"^2.8.1\"\n },\n \"devDependencies\": {\n \"@types/mocha\": \"^10.0.10\"\n },\n \"peerDependencies\": {\n \"arktype\": \"^2.1.25\"\n }\n}","import pkg from '../package.json' with { type: 'json' };\nimport { OpenAPIArkHelper, PostmanArkHelper } from './doc-helpers.js';\nimport type {\n ArklessReqRef,\n ArklessReqRefDefaults,\n ValidatorArk,\n ValidatorArkReqRef,\n ValidatorArkSchema,\n} from './types.js';\nimport Boom from '@hapi/boom';\nimport type {\n KaapiServerRoute,\n HandlerDecorations,\n Lifecycle,\n KaapiPlugin,\n Request,\n ResponseToolkit,\n RouteOptions,\n} from '@kaapi/kaapi';\nimport { type, type Type } from 'arktype';\n\nconst { parse = { payload: true, query: true, params: true, headers: true, state: true } } = {};\nexport const supportedProps = ['payload', 'query', 'params', 'headers', 'state'] as const;\nconst normalizeBooleans = (obj: Record<string, unknown>) => {\n for (const key in obj) {\n const val = obj[key];\n if (typeof val === 'string') {\n if (val === 'true') obj[key] = true;\n else if (val === 'false') obj[key] = false;\n } else if (Array.isArray(val)) {\n obj[key] = val.map((v) => (v === 'true' ? true : v === 'false' ? false : v));\n }\n }\n return obj;\n};\n\nfunction mergeOptions<V extends ValidatorArkSchema, R extends ArklessReqRef>(\n options: RouteOptions<ValidatorArkReqRef<V> & R>,\n schema: V\n) {\n // validator\n if (!options.plugins) {\n options.plugins = {};\n }\n options.plugins.ark = schema;\n\n // docs\n options.plugins.kaapi = options.plugins.kaapi || {};\n if (\n options.plugins.kaapi.docs != false && // docs not disabled\n !options.plugins.kaapi.docs?.disabled // docs not disabled\n ) {\n if (!options.plugins?.kaapi?.docs?.helperSchemaProperty)\n // docs have not helperSchemaProperty\n options.plugins.kaapi.docs = {\n ...options.plugins.kaapi.docs,\n helperSchemaProperty: 'ark',\n };\n if (!options.plugins?.kaapi?.docs?.openAPIHelperClass)\n // docs have not openAPIHelperClass\n options.plugins.kaapi.docs = {\n ...options.plugins.kaapi.docs,\n openAPIHelperClass: OpenAPIArkHelper,\n };\n }\n return options\n}\n\nexport const validatorArk: KaapiPlugin = {\n async integrate(t) {\n const validator: ValidatorArk = <V extends ValidatorArkSchema>(schema: V) => {\n return {\n route<R extends ArklessReqRef = ArklessReqRefDefaults>(\n serverRoute: KaapiServerRoute<ValidatorArkReqRef<V> & R>,\n handler?:\n | HandlerDecorations\n | Lifecycle.Method<ValidatorArkReqRef<V> & R, Lifecycle.ReturnValue<ValidatorArkReqRef<V> & R>>\n ) {\n if (!serverRoute.options) {\n serverRoute.options = {};\n }\n if (typeof serverRoute.options === 'object') {\n mergeOptions(serverRoute.options, schema)\n } else if (typeof serverRoute.options === 'function') {\n const fn = serverRoute.options.bind(serverRoute);\n serverRoute.options = (server) => {\n const options = fn(server)\n return mergeOptions(options, schema)\n }\n }\n t.route(serverRoute, handler);\n return t.server;\n },\n };\n };\n\n await t.server.register({\n name: 'kaapi-validator-arktype',\n version: pkg.version,\n register: async function (server) {\n server.ext('onPreHandler', async (request: Request, h: ResponseToolkit) => {\n const routeValidation = request?.route?.settings?.plugins?.ark as ValidatorArkSchema | undefined;\n try {\n // Initialize empty objects to hold the parsed data and corresponding ArkType schemas\n const data: Record<string, unknown> = {};\n const dataSchema: Record<string, Type> = {};\n\n // Loop through all supported properties for this route\n for (const prop of supportedProps) {\n // Check if validation exists for this property and there is a parser defined\n if (routeValidation?.[prop] && parse[prop]) {\n // Add the ArkType schema for this property to the dataSchema\n dataSchema[prop] = routeValidation[prop];\n // Prepare the value for parsing:\n // - For query params, normalize boolean strings to actual booleans\n // - Otherwise, take the raw value from the request object\n data[prop] = prop === 'query' ? normalizeBooleans(request[prop]) : request[prop];\n }\n }\n\n // Determine if there are any properties to validate\n let hasProps = false;\n for (const key in dataSchema) {\n // Safely check own properties to avoid inherited keys\n if (Object.prototype.hasOwnProperty.call(dataSchema, key)) {\n hasProps = true;\n break;\n }\n }\n\n // If we have any props to validate, parse them using ArkType\n if (hasProps) {\n // Create an ArkType object from the collected schema and parse\n const parsedProps = type(dataSchema)(data);\n if (parsedProps instanceof type.errors) {\n // throw ArkErrors\n throw parsedProps;\n }\n // Merge the parsed and validated properties back into the request object\n Object.assign(request, parsedProps);\n }\n\n // Continue the Hapi request lifecycle\n return h.continue;\n } catch (err) {\n // Initialize a set to track which paths (properties) failed validation\n const issuePaths = new Set<string>();\n let message: string;\n\n // Check if the error is instance of ValiError\n if (err instanceof type.errors && err.issues.length) {\n const firstIssue = err.issues[0];\n message = firstIssue.message;\n } else if (err instanceof Error) {\n // If it’s a regular Error, use its message\n message = err.message;\n } else {\n // Unknown error type\n message = 'Unknown error';\n }\n\n // Create a Boom badRequest response with the error message\n const response = Boom.badRequest(message);\n\n // Attach the raw validation error object for debugging/logging\n response.data = {\n validationError: err,\n };\n\n // Handle custom failAction if it’s a function\n if (typeof routeValidation?.failAction === 'function') {\n return routeValidation.failAction(request, h, response);\n }\n\n // If failAction is 'log', log the validation error with the request\n if (routeValidation?.failAction === 'log') {\n request.log(['validation', 'error', 'arktype', ...issuePaths], response);\n // Note: unlike Hapi's failAction 'log', 'log' here still returns a Boom response\n }\n\n // Return the error response to halt request processing\n return response;\n }\n });\n server.decorate('server', 'ark', validator);\n },\n });\n\n if (t.openapi) {\n t.openapi.addHelperClass(OpenAPIArkHelper);\n }\n if (t.postman) {\n t.postman.addHelperClass(PostmanArkHelper);\n }\n },\n};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AAM,WAAW,KAAK,WAAW,OAAO;AAGxC,qBAAS,OAAO;AAAA,cACZ,iBAAiB;AAAA,YACrB;AAGA,gBAAI,OAAO,iBAAiB,eAAe,YAAY;AACnD,qBAAO,gBAAgB,WAAW,SAAS,GAAG,QAAQ;AAAA,YAC1D;AAGA,gBAAI,iBAAiB,eAAe,OAAO;AACvC,sBAAQ,IAAI,CAAC,cAAc,SAAS,WAAW,GAAG,UAAU,GAAG,QAAQ;AAAA,YAE3E;AAGA,mBAAO;AAAA,UACX;AAAA,QACJ,CAAC;AACD,eAAO,SAAS,UAAU,OAAO,SAAS;AAAA,MAC9C;AAAA,IACJ,CAAC;AAED,QAAI,EAAE,SAAS;AACX,QAAE,QAAQ,eAAe,gBAAgB;AAAA,IAC7C;AACA,QAAI,EAAE,SAAS;AACX,QAAE,QAAQ,eAAe,gBAAgB;AAAA,IAC7C;AAAA,EACJ;AACJ;","names":[]}
@@ -17,11 +17,13 @@ declare class OpenAPIArkHelper extends OpenAPIJsonHelper implements KaapiOpenAPI
17
17
  getFilesChildren(): Record<string, unknown>;
18
18
  }
19
19
  declare class PostmanArkHelper extends PostmanJsonHelper {
20
+ protected _originalSchema?: Type;
20
21
  constructor(params: {
21
22
  value?: Type | object | unknown;
22
23
  isRoot?: boolean;
23
24
  }, isRequired?: boolean);
24
25
  isValid(): boolean;
26
+ isRequired(): boolean;
25
27
  getFirstItem(): PostmanArkHelper | undefined;
26
28
  getChildren(): Record<string, PostmanArkHelper>;
27
29
  getAlternatives(): PostmanArkHelper[];
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  OpenAPIArkHelper,
3
3
  PostmanArkHelper
4
- } from "./chunk-ML2GHWVG.js";
4
+ } from "./chunk-QLKH743P.js";
5
5
  export {
6
6
  OpenAPIArkHelper,
7
7
  PostmanArkHelper
package/lib/index.js CHANGED
@@ -2,11 +2,11 @@ import "./chunk-55J6XMHW.js";
2
2
  import {
3
3
  supportedProps,
4
4
  validatorArk
5
- } from "./chunk-4FGTS4GA.js";
5
+ } from "./chunk-U7WK3Q5P.js";
6
6
  import {
7
7
  OpenAPIArkHelper,
8
8
  PostmanArkHelper
9
- } from "./chunk-ML2GHWVG.js";
9
+ } from "./chunk-QLKH743P.js";
10
10
  export {
11
11
  OpenAPIArkHelper,
12
12
  PostmanArkHelper,
@@ -1 +1 @@
1
- {"inputs":{"src/doc-helpers.ts":{"bytes":9157,"imports":[{"path":"@novice1/api-doc-json-helper","kind":"import-statement","external":true},{"path":"arktype","kind":"import-statement","external":true}],"format":"esm"},"src/types.ts":{"bytes":1833,"imports":[],"format":"esm"},"package.json":{"bytes":1797,"imports":[],"format":"esm","with":{"type":"json"}},"src/validator.ts":{"bytes":8672,"imports":[{"path":"package.json","kind":"import-statement","original":"../package.json","with":{"type":"json"}},{"path":"src/doc-helpers.ts","kind":"import-statement","original":"./doc-helpers.js"},{"path":"@hapi/boom","kind":"import-statement","external":true},{"path":"arktype","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":94,"imports":[{"path":"src/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/doc-helpers.ts","kind":"import-statement","original":"./doc-helpers.js"},{"path":"src/validator.ts","kind":"import-statement","original":"./validator.js"}],"format":"esm"}},"outputs":{"lib/doc-helpers.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"lib/doc-helpers.js":{"imports":[{"path":"lib/chunk-ML2GHWVG.js","kind":"import-statement"}],"exports":["OpenAPIArkHelper","PostmanArkHelper"],"entryPoint":"src/doc-helpers.ts","inputs":{},"bytes":129},"lib/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"lib/index.js":{"imports":[{"path":"lib/chunk-55J6XMHW.js","kind":"import-statement"},{"path":"lib/chunk-4FGTS4GA.js","kind":"import-statement"},{"path":"lib/chunk-ML2GHWVG.js","kind":"import-statement"}],"exports":["OpenAPIArkHelper","PostmanArkHelper","supportedProps","validatorArk"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":265},"lib/types.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"lib/types.js":{"imports":[{"path":"lib/chunk-55J6XMHW.js","kind":"import-statement"}],"exports":[],"entryPoint":"src/types.ts","inputs":{},"bytes":30},"lib/chunk-55J6XMHW.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"lib/chunk-55J6XMHW.js":{"imports":[],"exports":[],"inputs":{"src/types.ts":{"bytesInOutput":0}},"bytes":0},"lib/validator.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"lib/validator.js":{"imports":[{"path":"lib/chunk-4FGTS4GA.js","kind":"import-statement"},{"path":"lib/chunk-ML2GHWVG.js","kind":"import-statement"}],"exports":["supportedProps","validatorArk"],"entryPoint":"src/validator.ts","inputs":{},"bytes":147},"lib/chunk-4FGTS4GA.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":14610},"lib/chunk-4FGTS4GA.js":{"imports":[{"path":"lib/chunk-ML2GHWVG.js","kind":"import-statement"},{"path":"@hapi/boom","kind":"import-statement","external":true},{"path":"arktype","kind":"import-statement","external":true}],"exports":["supportedProps","validatorArk"],"inputs":{"package.json":{"bytesInOutput":1758},"src/validator.ts":{"bytesInOutput":4350}},"bytes":6270},"lib/chunk-ML2GHWVG.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":14190},"lib/chunk-ML2GHWVG.js":{"imports":[{"path":"@novice1/api-doc-json-helper","kind":"import-statement","external":true},{"path":"arktype","kind":"import-statement","external":true}],"exports":["OpenAPIArkHelper","PostmanArkHelper"],"inputs":{"src/doc-helpers.ts":{"bytesInOutput":6443}},"bytes":6517}}}
1
+ {"inputs":{"src/doc-helpers.ts":{"bytes":13491,"imports":[{"path":"@novice1/api-doc-json-helper","kind":"import-statement","external":true},{"path":"arktype","kind":"import-statement","external":true}],"format":"esm"},"src/types.ts":{"bytes":1833,"imports":[],"format":"esm"},"package.json":{"bytes":1796,"imports":[],"format":"esm","with":{"type":"json"}},"src/validator.ts":{"bytes":8672,"imports":[{"path":"package.json","kind":"import-statement","original":"../package.json","with":{"type":"json"}},{"path":"src/doc-helpers.ts","kind":"import-statement","original":"./doc-helpers.js"},{"path":"@hapi/boom","kind":"import-statement","external":true},{"path":"arktype","kind":"import-statement","external":true}],"format":"esm"},"src/index.ts":{"bytes":94,"imports":[{"path":"src/types.ts","kind":"import-statement","original":"./types.js"},{"path":"src/doc-helpers.ts","kind":"import-statement","original":"./doc-helpers.js"},{"path":"src/validator.ts","kind":"import-statement","original":"./validator.js"}],"format":"esm"}},"outputs":{"lib/doc-helpers.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"lib/doc-helpers.js":{"imports":[{"path":"lib/chunk-QLKH743P.js","kind":"import-statement"}],"exports":["OpenAPIArkHelper","PostmanArkHelper"],"entryPoint":"src/doc-helpers.ts","inputs":{},"bytes":129},"lib/index.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"lib/index.js":{"imports":[{"path":"lib/chunk-55J6XMHW.js","kind":"import-statement"},{"path":"lib/chunk-U7WK3Q5P.js","kind":"import-statement"},{"path":"lib/chunk-QLKH743P.js","kind":"import-statement"}],"exports":["OpenAPIArkHelper","PostmanArkHelper","supportedProps","validatorArk"],"entryPoint":"src/index.ts","inputs":{"src/index.ts":{"bytesInOutput":0}},"bytes":265},"lib/types.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"lib/types.js":{"imports":[{"path":"lib/chunk-55J6XMHW.js","kind":"import-statement"}],"exports":[],"entryPoint":"src/types.ts","inputs":{},"bytes":30},"lib/chunk-55J6XMHW.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"lib/chunk-55J6XMHW.js":{"imports":[],"exports":[],"inputs":{"src/types.ts":{"bytesInOutput":0}},"bytes":0},"lib/validator.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":93},"lib/validator.js":{"imports":[{"path":"lib/chunk-U7WK3Q5P.js","kind":"import-statement"},{"path":"lib/chunk-QLKH743P.js","kind":"import-statement"}],"exports":["supportedProps","validatorArk"],"entryPoint":"src/validator.ts","inputs":{},"bytes":147},"lib/chunk-U7WK3Q5P.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":14608},"lib/chunk-U7WK3Q5P.js":{"imports":[{"path":"lib/chunk-QLKH743P.js","kind":"import-statement"},{"path":"@hapi/boom","kind":"import-statement","external":true},{"path":"arktype","kind":"import-statement","external":true}],"exports":["supportedProps","validatorArk"],"inputs":{"package.json":{"bytesInOutput":1758},"src/validator.ts":{"bytesInOutput":4350}},"bytes":6270},"lib/chunk-QLKH743P.js.map":{"imports":[],"exports":[],"inputs":{},"bytes":20569},"lib/chunk-QLKH743P.js":{"imports":[{"path":"@novice1/api-doc-json-helper","kind":"import-statement","external":true},{"path":"arktype","kind":"import-statement","external":true}],"exports":["OpenAPIArkHelper","PostmanArkHelper"],"inputs":{"src/doc-helpers.ts":{"bytesInOutput":9196}},"bytes":9270}}}
package/lib/validator.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  supportedProps,
3
3
  validatorArk
4
- } from "./chunk-4FGTS4GA.js";
5
- import "./chunk-ML2GHWVG.js";
4
+ } from "./chunk-U7WK3Q5P.js";
5
+ import "./chunk-QLKH743P.js";
6
6
  export {
7
7
  supportedProps,
8
8
  validatorArk
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@kaapi/validator-arktype",
3
3
  "type": "module",
4
- "version": "0.0.32",
4
+ "version": "0.0.34",
5
5
  "private": false,
6
6
  "description": "ArkType-powered request validation and documentation plugin for Kaapi.",
7
7
  "main": "lib/index.js",
@@ -27,10 +27,10 @@
27
27
  "license": "MIT",
28
28
  "dependencies": {
29
29
  "@hapi/boom": "^10.0.1",
30
- "@novice1/api-doc-json-helper": "^1.0.6",
30
+ "@novice1/api-doc-json-helper": "^1.0.8",
31
31
  "arktype": "^2.1.25",
32
32
  "tslib": "^2.8.1",
33
- "@kaapi/kaapi": "^0.0.32"
33
+ "@kaapi/kaapi": "^0.0.34"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@types/mocha": "^10.0.10"
@@ -1,224 +0,0 @@
1
- body, html {
2
- margin:0; padding: 0;
3
- height: 100%;
4
- }
5
- body {
6
- font-family: Helvetica Neue, Helvetica, Arial;
7
- font-size: 14px;
8
- color:#333;
9
- }
10
- .small { font-size: 12px; }
11
- *, *:after, *:before {
12
- -webkit-box-sizing:border-box;
13
- -moz-box-sizing:border-box;
14
- box-sizing:border-box;
15
- }
16
- h1 { font-size: 20px; margin: 0;}
17
- h2 { font-size: 14px; }
18
- pre {
19
- font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
20
- margin: 0;
21
- padding: 0;
22
- -moz-tab-size: 2;
23
- -o-tab-size: 2;
24
- tab-size: 2;
25
- }
26
- a { color:#0074D9; text-decoration:none; }
27
- a:hover { text-decoration:underline; }
28
- .strong { font-weight: bold; }
29
- .space-top1 { padding: 10px 0 0 0; }
30
- .pad2y { padding: 20px 0; }
31
- .pad1y { padding: 10px 0; }
32
- .pad2x { padding: 0 20px; }
33
- .pad2 { padding: 20px; }
34
- .pad1 { padding: 10px; }
35
- .space-left2 { padding-left:55px; }
36
- .space-right2 { padding-right:20px; }
37
- .center { text-align:center; }
38
- .clearfix { display:block; }
39
- .clearfix:after {
40
- content:'';
41
- display:block;
42
- height:0;
43
- clear:both;
44
- visibility:hidden;
45
- }
46
- .fl { float: left; }
47
- @media only screen and (max-width:640px) {
48
- .col3 { width:100%; max-width:100%; }
49
- .hide-mobile { display:none!important; }
50
- }
51
-
52
- .quiet {
53
- color: #7f7f7f;
54
- color: rgba(0,0,0,0.5);
55
- }
56
- .quiet a { opacity: 0.7; }
57
-
58
- .fraction {
59
- font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
60
- font-size: 10px;
61
- color: #555;
62
- background: #E8E8E8;
63
- padding: 4px 5px;
64
- border-radius: 3px;
65
- vertical-align: middle;
66
- }
67
-
68
- div.path a:link, div.path a:visited { color: #333; }
69
- table.coverage {
70
- border-collapse: collapse;
71
- margin: 10px 0 0 0;
72
- padding: 0;
73
- }
74
-
75
- table.coverage td {
76
- margin: 0;
77
- padding: 0;
78
- vertical-align: top;
79
- }
80
- table.coverage td.line-count {
81
- text-align: right;
82
- padding: 0 5px 0 20px;
83
- }
84
- table.coverage td.line-coverage {
85
- text-align: right;
86
- padding-right: 10px;
87
- min-width:20px;
88
- }
89
-
90
- table.coverage td span.cline-any {
91
- display: inline-block;
92
- padding: 0 5px;
93
- width: 100%;
94
- }
95
- .missing-if-branch {
96
- display: inline-block;
97
- margin-right: 5px;
98
- border-radius: 3px;
99
- position: relative;
100
- padding: 0 4px;
101
- background: #333;
102
- color: yellow;
103
- }
104
-
105
- .skip-if-branch {
106
- display: none;
107
- margin-right: 10px;
108
- position: relative;
109
- padding: 0 4px;
110
- background: #ccc;
111
- color: white;
112
- }
113
- .missing-if-branch .typ, .skip-if-branch .typ {
114
- color: inherit !important;
115
- }
116
- .coverage-summary {
117
- border-collapse: collapse;
118
- width: 100%;
119
- }
120
- .coverage-summary tr { border-bottom: 1px solid #bbb; }
121
- .keyline-all { border: 1px solid #ddd; }
122
- .coverage-summary td, .coverage-summary th { padding: 10px; }
123
- .coverage-summary tbody { border: 1px solid #bbb; }
124
- .coverage-summary td { border-right: 1px solid #bbb; }
125
- .coverage-summary td:last-child { border-right: none; }
126
- .coverage-summary th {
127
- text-align: left;
128
- font-weight: normal;
129
- white-space: nowrap;
130
- }
131
- .coverage-summary th.file { border-right: none !important; }
132
- .coverage-summary th.pct { }
133
- .coverage-summary th.pic,
134
- .coverage-summary th.abs,
135
- .coverage-summary td.pct,
136
- .coverage-summary td.abs { text-align: right; }
137
- .coverage-summary td.file { white-space: nowrap; }
138
- .coverage-summary td.pic { min-width: 120px !important; }
139
- .coverage-summary tfoot td { }
140
-
141
- .coverage-summary .sorter {
142
- height: 10px;
143
- width: 7px;
144
- display: inline-block;
145
- margin-left: 0.5em;
146
- background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
147
- }
148
- .coverage-summary .sorted .sorter {
149
- background-position: 0 -20px;
150
- }
151
- .coverage-summary .sorted-desc .sorter {
152
- background-position: 0 -10px;
153
- }
154
- .status-line { height: 10px; }
155
- /* yellow */
156
- .cbranch-no { background: yellow !important; color: #111; }
157
- /* dark red */
158
- .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
159
- .low .chart { border:1px solid #C21F39 }
160
- .highlighted,
161
- .highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
162
- background: #C21F39 !important;
163
- }
164
- /* medium red */
165
- .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
166
- /* light red */
167
- .low, .cline-no { background:#FCE1E5 }
168
- /* light green */
169
- .high, .cline-yes { background:rgb(230,245,208) }
170
- /* medium green */
171
- .cstat-yes { background:rgb(161,215,106) }
172
- /* dark green */
173
- .status-line.high, .high .cover-fill { background:rgb(77,146,33) }
174
- .high .chart { border:1px solid rgb(77,146,33) }
175
- /* dark yellow (gold) */
176
- .status-line.medium, .medium .cover-fill { background: #f9cd0b; }
177
- .medium .chart { border:1px solid #f9cd0b; }
178
- /* light yellow */
179
- .medium { background: #fff4c2; }
180
-
181
- .cstat-skip { background: #ddd; color: #111; }
182
- .fstat-skip { background: #ddd; color: #111 !important; }
183
- .cbranch-skip { background: #ddd !important; color: #111; }
184
-
185
- span.cline-neutral { background: #eaeaea; }
186
-
187
- .coverage-summary td.empty {
188
- opacity: .5;
189
- padding-top: 4px;
190
- padding-bottom: 4px;
191
- line-height: 1;
192
- color: #888;
193
- }
194
-
195
- .cover-fill, .cover-empty {
196
- display:inline-block;
197
- height: 12px;
198
- }
199
- .chart {
200
- line-height: 0;
201
- }
202
- .cover-empty {
203
- background: white;
204
- }
205
- .cover-full {
206
- border-right: none !important;
207
- }
208
- pre.prettyprint {
209
- border: none !important;
210
- padding: 0 !important;
211
- margin: 0 !important;
212
- }
213
- .com { color: #999 !important; }
214
- .ignore-none { color: #999; font-weight: normal; }
215
-
216
- .wrapper {
217
- min-height: 100%;
218
- height: auto !important;
219
- height: 100%;
220
- margin: 0 auto -48px;
221
- }
222
- .footer, .push {
223
- height: 48px;
224
- }
@@ -1,87 +0,0 @@
1
- /* eslint-disable */
2
- var jumpToCode = (function init() {
3
- // Classes of code we would like to highlight in the file view
4
- var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
5
-
6
- // Elements to highlight in the file listing view
7
- var fileListingElements = ['td.pct.low'];
8
-
9
- // We don't want to select elements that are direct descendants of another match
10
- var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
11
-
12
- // Selector that finds elements on the page to which we can jump
13
- var selector =
14
- fileListingElements.join(', ') +
15
- ', ' +
16
- notSelector +
17
- missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
18
-
19
- // The NodeList of matching elements
20
- var missingCoverageElements = document.querySelectorAll(selector);
21
-
22
- var currentIndex;
23
-
24
- function toggleClass(index) {
25
- missingCoverageElements
26
- .item(currentIndex)
27
- .classList.remove('highlighted');
28
- missingCoverageElements.item(index).classList.add('highlighted');
29
- }
30
-
31
- function makeCurrent(index) {
32
- toggleClass(index);
33
- currentIndex = index;
34
- missingCoverageElements.item(index).scrollIntoView({
35
- behavior: 'smooth',
36
- block: 'center',
37
- inline: 'center'
38
- });
39
- }
40
-
41
- function goToPrevious() {
42
- var nextIndex = 0;
43
- if (typeof currentIndex !== 'number' || currentIndex === 0) {
44
- nextIndex = missingCoverageElements.length - 1;
45
- } else if (missingCoverageElements.length > 1) {
46
- nextIndex = currentIndex - 1;
47
- }
48
-
49
- makeCurrent(nextIndex);
50
- }
51
-
52
- function goToNext() {
53
- var nextIndex = 0;
54
-
55
- if (
56
- typeof currentIndex === 'number' &&
57
- currentIndex < missingCoverageElements.length - 1
58
- ) {
59
- nextIndex = currentIndex + 1;
60
- }
61
-
62
- makeCurrent(nextIndex);
63
- }
64
-
65
- return function jump(event) {
66
- if (
67
- document.getElementById('fileSearch') === document.activeElement &&
68
- document.activeElement != null
69
- ) {
70
- // if we're currently focused on the search input, we don't want to navigate
71
- return;
72
- }
73
-
74
- switch (event.which) {
75
- case 78: // n
76
- case 74: // j
77
- goToNext();
78
- break;
79
- case 66: // b
80
- case 75: // k
81
- case 80: // p
82
- goToPrevious();
83
- break;
84
- }
85
- };
86
- })();
87
- window.addEventListener('keydown', jumpToCode);
Binary file