@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.
- package/CHANGELOG.md +12 -0
- package/README.md +11 -0
- package/jest.integration.config.ts +26 -0
- package/jsonCompiler.ts +35 -2
- package/lib/JsonSchemaService.js +8 -7
- package/lib/JsonSchemaService.js.map +1 -1
- package/lib/JsonValidationService.d.ts +3 -2
- package/lib/JsonValidationService.js +21 -91
- package/lib/JsonValidationService.js.map +1 -1
- package/lib/defaultDraftConfig.d.ts +2 -0
- package/lib/defaultDraftConfig.js +81 -0
- package/lib/defaultDraftConfig.js.map +1 -0
- package/lib/formatted-text/v1/formattedTextConstants.d.ts +2 -0
- package/lib/formatted-text/v1/formattedTextConstants.js +6 -0
- package/lib/formatted-text/v1/formattedTextConstants.js.map +1 -0
- package/lib/formatted-text/v1/resolveFormattedTextNodes.d.ts +2 -2
- package/lib/formatted-text/v1/resolveFormattedTextNodes.js +3 -2
- package/lib/formatted-text/v1/resolveFormattedTextNodes.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/manifest/userApi/v1/UserApiManifestV1.d.ts +48 -0
- package/lib/manifest/userApi/v1/UserApiManifestV1.js +9 -0
- package/lib/manifest/userApi/v1/UserApiManifestV1.js.map +1 -0
- package/lib/manifest/userApi/v1/UserApiManifestV1.json +77 -0
- package/lib/manifest/userApi/v1/index.d.ts +2 -0
- package/lib/manifest/userApi/v1/index.js +8 -0
- package/lib/manifest/userApi/v1/index.js.map +1 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-extra-public.manifest.json +10 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-handler-hyphen.manifest.json +9 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-handler-leading-digit.manifest.json +9 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-method-invalid.manifest.json +9 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-missing-method.manifest.json +8 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-endpoint-missing-path.manifest.json +8 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-displayName-empty.manifest.json +16 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-manifest-not-object.manifest.json +8 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-missing-manifest.manifest.json +7 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-missing-schema.manifest.json +15 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-name-empty.manifest.json +16 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-full-root-extra-property.manifest.json +17 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-nested-manifest-handlerMap.manifest.json +12 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-nested-manifest-name.manifest.json +10 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-resolved-empty-endpoints.manifest.json +4 -0
- package/lib/manifest/userApi/v1/integration-fixtures/invalid-resolved-no-leading-slash.manifest.json +11 -0
- package/lib/manifest/userApi/v1/integration-fixtures/valid-full-each-http-method.manifest.json +18 -0
- package/lib/manifest/userApi/v1/integration-fixtures/valid-full-no-description.manifest.json +16 -0
- package/lib/manifest/userApi/v1/integration-fixtures/valid-full.manifest.json +22 -0
- package/lib/manifest/userApi/v1/integration-fixtures/valid-resolved-slash-path.manifest.json +14 -0
- package/lib/manifest/userApi/v1/integration-fixtures/valid-resolved.manifest.json +14 -0
- package/lib/manifest/userApi/v1/userApiManifest.integration.spec.d.ts +1 -0
- package/lib/manifest/userApi/v1/userApiManifest.integration.spec.js +201 -0
- package/lib/manifest/userApi/v1/userApiManifest.integration.spec.js.map +1 -0
- package/lib/manifest/userApi/v1/userApiManifestValidation.d.ts +16 -0
- package/lib/manifest/userApi/v1/userApiManifestValidation.js +88 -0
- package/lib/manifest/userApi/v1/userApiManifestValidation.js.map +1 -0
- package/lib/manifest/userApi/v1/userApiManifestValidation.spec.d.ts +1 -0
- package/lib/manifest/userApi/v1/userApiManifestValidation.spec.js +246 -0
- package/lib/manifest/userApi/v1/userApiManifestValidation.spec.js.map +1 -0
- package/package.json +11 -1
- package/src/JsonSchemaService.ts +2 -1
- package/src/JsonValidationService.ts +9 -96
- package/src/defaultDraftConfig.ts +89 -0
- package/src/formatted-text/v1/formattedTextConstants.ts +2 -0
- package/src/formatted-text/v1/resolveFormattedTextNodes.ts +3 -2
- package/src/index.ts +2 -0
- package/src/manifest/userApi/v1/UserApiManifestV1.json +77 -0
- package/src/manifest/userApi/v1/UserApiManifestV1.ts +50 -0
- package/src/manifest/userApi/v1/index.ts +6 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-extra-public.manifest.json +10 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-handler-hyphen.manifest.json +9 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-handler-leading-digit.manifest.json +9 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-method-invalid.manifest.json +9 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-missing-method.manifest.json +8 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-endpoint-missing-path.manifest.json +8 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-full-displayName-empty.manifest.json +16 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-full-manifest-not-object.manifest.json +8 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-full-missing-manifest.manifest.json +7 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-full-missing-schema.manifest.json +15 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-full-name-empty.manifest.json +16 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-full-root-extra-property.manifest.json +17 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-nested-manifest-handlerMap.manifest.json +12 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-nested-manifest-name.manifest.json +10 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-resolved-empty-endpoints.manifest.json +4 -0
- package/src/manifest/userApi/v1/integration-fixtures/invalid-resolved-no-leading-slash.manifest.json +11 -0
- package/src/manifest/userApi/v1/integration-fixtures/valid-full-each-http-method.manifest.json +18 -0
- package/src/manifest/userApi/v1/integration-fixtures/valid-full-no-description.manifest.json +16 -0
- package/src/manifest/userApi/v1/integration-fixtures/valid-full.manifest.json +22 -0
- package/src/manifest/userApi/v1/integration-fixtures/valid-resolved-slash-path.manifest.json +14 -0
- package/src/manifest/userApi/v1/integration-fixtures/valid-resolved.manifest.json +14 -0
- package/src/manifest/userApi/v1/userApiManifest.integration.spec.ts +265 -0
- package/src/manifest/userApi/v1/userApiManifestValidation.spec.ts +321 -0
- package/src/manifest/userApi/v1/userApiManifestValidation.ts +54 -0
- 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
|
+
}
|
package/src/manifest/userApi/v1/integration-fixtures/invalid-full-displayName-empty.manifest.json
ADDED
|
@@ -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
|
+
}
|
package/src/manifest/userApi/v1/integration-fixtures/invalid-full-manifest-not-object.manifest.json
ADDED
|
@@ -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,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
|
+
}
|
package/src/manifest/userApi/v1/integration-fixtures/invalid-full-root-extra-property.manifest.json
ADDED
|
@@ -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
|
+
}
|
package/src/manifest/userApi/v1/integration-fixtures/valid-full-each-http-method.manifest.json
ADDED
|
@@ -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
|
+
}
|