@squiz/dx-json-schema-lib 1.85.1 → 1.85.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.
Files changed (93) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +11 -0
  3. package/jest.integration.config.ts +26 -0
  4. package/jsonCompiler.ts +35 -2
  5. package/lib/JsonSchemaService.js +8 -7
  6. package/lib/JsonSchemaService.js.map +1 -1
  7. package/lib/JsonValidationService.d.ts +3 -2
  8. package/lib/JsonValidationService.js +21 -91
  9. package/lib/JsonValidationService.js.map +1 -1
  10. package/lib/defaultDraftConfig.d.ts +2 -0
  11. package/lib/defaultDraftConfig.js +81 -0
  12. package/lib/defaultDraftConfig.js.map +1 -0
  13. package/lib/formatted-text/v1/formattedTextConstants.d.ts +2 -0
  14. package/lib/formatted-text/v1/formattedTextConstants.js +6 -0
  15. package/lib/formatted-text/v1/formattedTextConstants.js.map +1 -0
  16. package/lib/formatted-text/v1/resolveFormattedTextNodes.d.ts +2 -2
  17. package/lib/formatted-text/v1/resolveFormattedTextNodes.js +3 -2
  18. package/lib/formatted-text/v1/resolveFormattedTextNodes.js.map +1 -1
  19. package/lib/index.d.ts +1 -0
  20. package/lib/index.js +1 -0
  21. package/lib/index.js.map +1 -1
  22. package/lib/manifest/userApi/v1/UserApiManifestV1.d.ts +48 -0
  23. package/lib/manifest/userApi/v1/UserApiManifestV1.js +9 -0
  24. package/lib/manifest/userApi/v1/UserApiManifestV1.js.map +1 -0
  25. package/lib/manifest/userApi/v1/UserApiManifestV1.json +77 -0
  26. package/lib/manifest/userApi/v1/index.d.ts +2 -0
  27. package/lib/manifest/userApi/v1/index.js +8 -0
  28. package/lib/manifest/userApi/v1/index.js.map +1 -0
  29. package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-extra-public.manifest.json +10 -0
  30. package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-handler-hyphen.manifest.json +9 -0
  31. package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-handler-leading-digit.manifest.json +9 -0
  32. package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-method-invalid.manifest.json +9 -0
  33. package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-missing-method.manifest.json +8 -0
  34. package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-missing-path.manifest.json +8 -0
  35. package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-displayName-empty.manifest.json +16 -0
  36. package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-manifest-not-object.manifest.json +8 -0
  37. package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-missing-manifest.manifest.json +7 -0
  38. package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-missing-schema.manifest.json +15 -0
  39. package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-name-empty.manifest.json +16 -0
  40. package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-root-extra-property.manifest.json +17 -0
  41. package/lib/manifest/userApi/v1/integration-fixtures/invalid-nested-manifest-handlerMap.manifest.json +12 -0
  42. package/lib/manifest/userApi/v1/integration-fixtures/invalid-nested-manifest-name.manifest.json +10 -0
  43. package/lib/manifest/userApi/v1/integration-fixtures/invalid-resolved-empty-endpoints.manifest.json +4 -0
  44. package/lib/manifest/userApi/v1/integration-fixtures/invalid-resolved-no-leading-slash.manifest.json +11 -0
  45. package/lib/manifest/userApi/v1/integration-fixtures/valid-full-each-http-method.manifest.json +18 -0
  46. package/lib/manifest/userApi/v1/integration-fixtures/valid-full-no-description.manifest.json +16 -0
  47. package/lib/manifest/userApi/v1/integration-fixtures/valid-full.manifest.json +22 -0
  48. package/lib/manifest/userApi/v1/integration-fixtures/valid-resolved-slash-path.manifest.json +14 -0
  49. package/lib/manifest/userApi/v1/integration-fixtures/valid-resolved.manifest.json +14 -0
  50. package/lib/manifest/userApi/v1/userApiManifest.integration.spec.d.ts +1 -0
  51. package/lib/manifest/userApi/v1/userApiManifest.integration.spec.js +201 -0
  52. package/lib/manifest/userApi/v1/userApiManifest.integration.spec.js.map +1 -0
  53. package/lib/manifest/userApi/v1/userApiManifestValidation.d.ts +16 -0
  54. package/lib/manifest/userApi/v1/userApiManifestValidation.js +88 -0
  55. package/lib/manifest/userApi/v1/userApiManifestValidation.js.map +1 -0
  56. package/lib/manifest/userApi/v1/userApiManifestValidation.spec.d.ts +1 -0
  57. package/lib/manifest/userApi/v1/userApiManifestValidation.spec.js +246 -0
  58. package/lib/manifest/userApi/v1/userApiManifestValidation.spec.js.map +1 -0
  59. package/package.json +11 -1
  60. package/src/JsonSchemaService.ts +2 -1
  61. package/src/JsonValidationService.ts +9 -96
  62. package/src/defaultDraftConfig.ts +89 -0
  63. package/src/formatted-text/v1/formattedTextConstants.ts +2 -0
  64. package/src/formatted-text/v1/resolveFormattedTextNodes.ts +3 -2
  65. package/src/index.ts +2 -0
  66. package/src/manifest/userApi/v1/UserApiManifestV1.json +77 -0
  67. package/src/manifest/userApi/v1/UserApiManifestV1.ts +50 -0
  68. package/src/manifest/userApi/v1/index.ts +6 -0
  69. package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-extra-public.manifest.json +10 -0
  70. package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-handler-hyphen.manifest.json +9 -0
  71. package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-handler-leading-digit.manifest.json +9 -0
  72. package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-method-invalid.manifest.json +9 -0
  73. package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-missing-method.manifest.json +8 -0
  74. package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-missing-path.manifest.json +8 -0
  75. package/src/manifest/userApi/v1/integration-fixtures/invalid-full-displayName-empty.manifest.json +16 -0
  76. package/src/manifest/userApi/v1/integration-fixtures/invalid-full-manifest-not-object.manifest.json +8 -0
  77. package/src/manifest/userApi/v1/integration-fixtures/invalid-full-missing-manifest.manifest.json +7 -0
  78. package/src/manifest/userApi/v1/integration-fixtures/invalid-full-missing-schema.manifest.json +15 -0
  79. package/src/manifest/userApi/v1/integration-fixtures/invalid-full-name-empty.manifest.json +16 -0
  80. package/src/manifest/userApi/v1/integration-fixtures/invalid-full-root-extra-property.manifest.json +17 -0
  81. package/src/manifest/userApi/v1/integration-fixtures/invalid-nested-manifest-handlerMap.manifest.json +12 -0
  82. package/src/manifest/userApi/v1/integration-fixtures/invalid-nested-manifest-name.manifest.json +10 -0
  83. package/src/manifest/userApi/v1/integration-fixtures/invalid-resolved-empty-endpoints.manifest.json +4 -0
  84. package/src/manifest/userApi/v1/integration-fixtures/invalid-resolved-no-leading-slash.manifest.json +11 -0
  85. package/src/manifest/userApi/v1/integration-fixtures/valid-full-each-http-method.manifest.json +18 -0
  86. package/src/manifest/userApi/v1/integration-fixtures/valid-full-no-description.manifest.json +16 -0
  87. package/src/manifest/userApi/v1/integration-fixtures/valid-full.manifest.json +22 -0
  88. package/src/manifest/userApi/v1/integration-fixtures/valid-resolved-slash-path.manifest.json +14 -0
  89. package/src/manifest/userApi/v1/integration-fixtures/valid-resolved.manifest.json +14 -0
  90. package/src/manifest/userApi/v1/userApiManifest.integration.spec.ts +265 -0
  91. package/src/manifest/userApi/v1/userApiManifestValidation.spec.ts +321 -0
  92. package/src/manifest/userApi/v1/userApiManifestValidation.ts +54 -0
  93. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,77 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "$id": "https://unpkg.com/@squiz/dx-json-schema-lib@latest/lib/manifest/userApiManifest/UserApiManifestV1.json",
4
+ "title": "UserApiManifestV1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "definitions": {
8
+ "resolvedApiManifest": {
9
+ "type": "object",
10
+ "additionalProperties": false,
11
+ "required": ["endpoints"],
12
+ "properties": {
13
+ "endpoints": {
14
+ "type": "array",
15
+ "minItems": 1,
16
+ "items": {
17
+ "type": "object",
18
+ "additionalProperties": false,
19
+ "required": ["path", "method", "handler"],
20
+ "properties": {
21
+ "path": {
22
+ "type": "string",
23
+ "pattern": "^/.*",
24
+ "description": "URL path routed to this endpoint; must start with /. May include `*` wildcards or `:param` segments (api-builder style)."
25
+ },
26
+ "method": {
27
+ "type": "string",
28
+ "enum": ["GET", "POST", "PUT", "PATCH", "DELETE", "OPTIONS", "HEAD"],
29
+ "description": "HTTP method for this route."
30
+ },
31
+ "handler": {
32
+ "type": "string",
33
+ "pattern": "^[a-zA-Z_$][a-zA-Z0-9_$.]*$",
34
+ "description": "Exported handler reference (module.export form)."
35
+ }
36
+ }
37
+ }
38
+ }
39
+ }
40
+ }
41
+ },
42
+ "required": ["$schema", "name", "displayName", "filesDir", "entry", "manifest"],
43
+ "properties": {
44
+ "$schema": {
45
+ "type": "string",
46
+ "minLength": 1,
47
+ "description": "JSON Schema reference for IDE support."
48
+ },
49
+ "name": {
50
+ "type": "string",
51
+ "minLength": 1,
52
+ "pattern": "^[a-z](?:[a-z0-9-]|_(?!_))*[a-z0-9]$",
53
+ "description": "Slug for this deployment. Lowercase letters, digits, hyphens, or underscores only; must start with a letter, end with a letter or digit, and cannot contain consecutive underscores."
54
+ },
55
+ "displayName": {
56
+ "type": "string",
57
+ "minLength": 1
58
+ },
59
+ "description": {
60
+ "type": "string",
61
+ "description": "Human-readable summary of what the API provides."
62
+ },
63
+ "filesDir": {
64
+ "type": "string",
65
+ "minLength": 1,
66
+ "description": "Directory (relative to the manifest) containing sources."
67
+ },
68
+ "entry": {
69
+ "type": "string",
70
+ "minLength": 1,
71
+ "description": "Entry module path under filesDir (e.g. index.ts)."
72
+ },
73
+ "manifest": {
74
+ "$ref": "#/definitions/resolvedApiManifest"
75
+ }
76
+ }
77
+ }
@@ -0,0 +1,50 @@
1
+ /* eslint-disable */
2
+ /**
3
+ * This file was automatically generated by json-schema-to-typescript.
4
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
+ * and run json-schema-to-typescript to regenerate this file.
6
+ */
7
+
8
+ export interface UserApiManifestV1 {
9
+ /**
10
+ * JSON Schema reference for IDE support.
11
+ */
12
+ $schema: string;
13
+ /**
14
+ * Slug for this deployment. Lowercase letters, digits, hyphens, or underscores only; must start with a letter, end with a letter or digit, and cannot contain consecutive underscores.
15
+ */
16
+ name: string;
17
+ displayName: string;
18
+ /**
19
+ * Human-readable summary of what the API provides.
20
+ */
21
+ description?: string;
22
+ /**
23
+ * Directory (relative to the manifest) containing sources.
24
+ */
25
+ filesDir: string;
26
+ /**
27
+ * Entry module path under filesDir (e.g. index.ts).
28
+ */
29
+ entry: string;
30
+ manifest: ResolvedApiManifest;
31
+ }
32
+ export interface ResolvedApiManifest {
33
+ /**
34
+ * @minItems 1
35
+ */
36
+ endpoints: {
37
+ /**
38
+ * URL path routed to this endpoint; must start with /. May include `*` wildcards or `:param` segments (api-builder style).
39
+ */
40
+ path: string;
41
+ /**
42
+ * HTTP method for this route.
43
+ */
44
+ method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'OPTIONS' | 'HEAD';
45
+ /**
46
+ * Exported handler reference (module.export form).
47
+ */
48
+ handler: string;
49
+ }[];
50
+ }
@@ -0,0 +1,6 @@
1
+ export {
2
+ USER_API_FULL_MANIFEST_SCHEMA,
3
+ USER_API_MANIFEST_SCHEMA_URL,
4
+ validateUserApiFullManifest,
5
+ } from './userApiManifestValidation';
6
+ export type { UserApiManifestV1 as UserApiManifest } from './UserApiManifestV1';
@@ -0,0 +1,10 @@
1
+ {
2
+ "endpoints": [
3
+ {
4
+ "path": "/ok",
5
+ "method": "GET",
6
+ "handler": "noop",
7
+ "public": true
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "endpoints": [
3
+ {
4
+ "path": "/ok",
5
+ "method": "GET",
6
+ "handler": "bad-name"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "endpoints": [
3
+ {
4
+ "path": "/ok",
5
+ "method": "GET",
6
+ "handler": "0badIdentifier"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "endpoints": [
3
+ {
4
+ "path": "/ok",
5
+ "method": "TRACE",
6
+ "handler": "noop"
7
+ }
8
+ ]
9
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "endpoints": [
3
+ {
4
+ "path": "/ok",
5
+ "handler": "noop"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "endpoints": [
3
+ {
4
+ "method": "GET",
5
+ "handler": "noop"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@squiz/dx-json-schema-lib@latest/lib/manifest/userApiManifest/UserApiManifestV1.json",
3
+ "name": "needs-display-name",
4
+ "displayName": "",
5
+ "filesDir": "src",
6
+ "entry": "index.ts",
7
+ "manifest": {
8
+ "endpoints": [
9
+ {
10
+ "path": "/only",
11
+ "method": "GET",
12
+ "handler": "h"
13
+ }
14
+ ]
15
+ }
16
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@squiz/dx-json-schema-lib@latest/lib/manifest/userApiManifest/UserApiManifestV1.json",
3
+ "name": "bad-manifest-shape",
4
+ "displayName": "Manifest not an object",
5
+ "filesDir": "src",
6
+ "entry": "index.ts",
7
+ "manifest": "not-an-object"
8
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@squiz/dx-json-schema-lib@latest/lib/manifest/userApiManifest/UserApiManifestV1.json",
3
+ "name": "missing-nested-manifest",
4
+ "displayName": "Manifest object absent",
5
+ "filesDir": "src",
6
+ "entry": "index.ts"
7
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "name": "missing-dollar-schema",
3
+ "displayName": "Missing dollar schema field",
4
+ "filesDir": "src",
5
+ "entry": "index.ts",
6
+ "manifest": {
7
+ "endpoints": [
8
+ {
9
+ "path": "/only",
10
+ "method": "GET",
11
+ "handler": "h"
12
+ }
13
+ ]
14
+ }
15
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@squiz/dx-json-schema-lib@latest/lib/manifest/userApiManifest/UserApiManifestV1.json",
3
+ "name": "",
4
+ "displayName": "Empty slug",
5
+ "filesDir": "src",
6
+ "entry": "index.ts",
7
+ "manifest": {
8
+ "endpoints": [
9
+ {
10
+ "path": "/only",
11
+ "method": "GET",
12
+ "handler": "h"
13
+ }
14
+ ]
15
+ }
16
+ }
@@ -0,0 +1,17 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@squiz/dx-json-schema-lib@latest/lib/manifest/userApiManifest/UserApiManifestV1.json",
3
+ "name": "extra-root-prop",
4
+ "displayName": "Extra root prop",
5
+ "filesDir": "src",
6
+ "entry": "index.ts",
7
+ "manifest": {
8
+ "endpoints": [
9
+ {
10
+ "path": "/only",
11
+ "method": "GET",
12
+ "handler": "h"
13
+ }
14
+ ]
15
+ },
16
+ "telemetryChannel": "forbidden-root-key-example"
17
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "endpoints": [
3
+ {
4
+ "path": "/ok",
5
+ "method": "GET",
6
+ "handler": "noop"
7
+ }
8
+ ],
9
+ "handlerMap": {
10
+ "noop": "./noop.ts"
11
+ }
12
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "must-not-live-under-manifest",
3
+ "endpoints": [
4
+ {
5
+ "path": "/ok",
6
+ "method": "GET",
7
+ "handler": "noop"
8
+ }
9
+ ]
10
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "name": "integration-sample-api",
3
+ "endpoints": []
4
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "integration-sample-api",
3
+ "endpoints": [
4
+ {
5
+ "path": "needs-leading-slash",
6
+ "method": "GET",
7
+ "handler": "index.x",
8
+ "public": true
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,18 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@squiz/dx-json-schema-lib@latest/lib/manifest/userApiManifest/UserApiManifestV1.json",
3
+ "name": "all-methods-api",
4
+ "displayName": "Covers enum methods",
5
+ "filesDir": "src",
6
+ "entry": "index.ts",
7
+ "manifest": {
8
+ "endpoints": [
9
+ { "path": "/g", "method": "GET", "handler": "handlers.g" },
10
+ { "path": "/po", "method": "POST", "handler": "handlers.po" },
11
+ { "path": "/pu", "method": "PUT", "handler": "handlers.pu" },
12
+ { "path": "/pa", "method": "PATCH", "handler": "handlers.pa" },
13
+ { "path": "/d", "method": "DELETE", "handler": "handlers.d" },
14
+ { "path": "/o", "method": "OPTIONS", "handler": "handlers.o" },
15
+ { "path": "/h", "method": "HEAD", "handler": "handlers.h" }
16
+ ]
17
+ }
18
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@squiz/dx-json-schema-lib@latest/lib/manifest/userApiManifest/UserApiManifestV1.json",
3
+ "name": "no-description-api",
4
+ "displayName": "No optional description field",
5
+ "filesDir": "src",
6
+ "entry": "index.ts",
7
+ "manifest": {
8
+ "endpoints": [
9
+ {
10
+ "path": "/health",
11
+ "method": "GET",
12
+ "handler": "health"
13
+ }
14
+ ]
15
+ }
16
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://unpkg.com/@squiz/dx-json-schema-lib@latest/lib/manifest/userApiManifest/UserApiManifestV1.json",
3
+ "name": "integration-sample-api",
4
+ "displayName": "Integration sample API",
5
+ "description": "Fixture used only by filesystem-backed integration tests",
6
+ "filesDir": "src",
7
+ "entry": "index.ts",
8
+ "manifest": {
9
+ "endpoints": [
10
+ {
11
+ "path": "/integration/hello",
12
+ "method": "GET",
13
+ "handler": "index.helloWorld"
14
+ },
15
+ {
16
+ "path": "/integration/items",
17
+ "method": "POST",
18
+ "handler": "handlers.createItem"
19
+ }
20
+ ]
21
+ }
22
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "endpoints": [
3
+ {
4
+ "path": "/",
5
+ "method": "GET",
6
+ "handler": "root"
7
+ },
8
+ {
9
+ "path": "/integration/items",
10
+ "method": "POST",
11
+ "handler": "handlers.createItem"
12
+ }
13
+ ]
14
+ }
@@ -0,0 +1,14 @@
1
+ {
2
+ "endpoints": [
3
+ {
4
+ "path": "/integration/hello",
5
+ "method": "GET",
6
+ "handler": "index.helloWorld"
7
+ },
8
+ {
9
+ "path": "/integration/items",
10
+ "method": "POST",
11
+ "handler": "handlers.createItem"
12
+ }
13
+ ]
14
+ }