@apicurio/artifact-type-builtins 3.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/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# @apicurio/artifact-type-builtins
|
|
2
|
+
|
|
3
|
+
Built-in functions and TypeScript type definitions for creating custom artifact types in Apicurio
|
|
4
|
+
Registry.
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
This package provides the TypeScript type definitions and built-in utility functions needed to develop
|
|
9
|
+
custom artifact types for [Apicurio Registry](https://www.apicur.io/registry/). It enables type safety
|
|
10
|
+
and IDE autocomplete support when implementing custom artifact type handlers in JavaScript/TypeScript.
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @apicurio/artifact-type-builtins
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Usage
|
|
19
|
+
|
|
20
|
+
Import the types and built-in functions in your custom artifact type implementation:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import {
|
|
24
|
+
ArtifactTypeScriptProvider,
|
|
25
|
+
info,
|
|
26
|
+
debug
|
|
27
|
+
} from '@apicurio/artifact-type-builtins';
|
|
28
|
+
|
|
29
|
+
export function acceptsContent(request: any): boolean {
|
|
30
|
+
info('Checking if content is accepted');
|
|
31
|
+
// Your implementation here
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function validate(request: any): any {
|
|
36
|
+
debug('Validating artifact content');
|
|
37
|
+
// Your implementation here
|
|
38
|
+
return {
|
|
39
|
+
ruleViolations: []
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// Implement other required functions...
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Example
|
|
47
|
+
|
|
48
|
+
For a complete example of creating a custom artifact type, see the
|
|
49
|
+
[TOML Artifact Type Example](https://github.com/Apicurio/apicurio-registry/tree/main/examples/custom-artifact-type)
|
|
50
|
+
in the Apicurio Registry repository.
|
|
51
|
+
|
|
52
|
+
## License
|
|
53
|
+
|
|
54
|
+
Apache License 2.0
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
// Generated by quarkus-quickjs4j
|
|
2
|
+
// TypeScript definitions for ArtifactTypeScriptProvider
|
|
3
|
+
|
|
4
|
+
// =============================================================================
|
|
5
|
+
// Context Builtins - Java methods callable from JavaScript
|
|
6
|
+
// =============================================================================
|
|
7
|
+
|
|
8
|
+
export function info(message: string): void;
|
|
9
|
+
export function debug(message: string): void;
|
|
10
|
+
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// Script Interface - Functions that must be implemented and exported
|
|
13
|
+
// =============================================================================
|
|
14
|
+
|
|
15
|
+
export interface ArtifactTypeScriptProvider {
|
|
16
|
+
acceptsContent(request: ContentAccepterRequest): boolean;
|
|
17
|
+
testCompatibility(request: CompatibilityCheckerRequest): CompatibilityCheckerResponse;
|
|
18
|
+
canonicalize(request: ContentCanonicalizerRequest): ContentCanonicalizerResponse;
|
|
19
|
+
dereference(request: ContentDereferencerRequest): ContentDereferencerResponse;
|
|
20
|
+
rewriteReferences(request: ContentDereferencerRequest): ContentDereferencerResponse;
|
|
21
|
+
validate(request: ContentValidatorRequest): ContentValidatorResponse;
|
|
22
|
+
validateReferences(request: ContentValidatorRequest): ContentValidatorResponse;
|
|
23
|
+
findExternalReferences(request: ReferenceFinderRequest): ReferenceFinderResponse;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// =============================================================================
|
|
27
|
+
// Type Definitions - TypeScript interfaces for Java beans
|
|
28
|
+
// =============================================================================
|
|
29
|
+
|
|
30
|
+
export interface CompatibilityCheckerResponse {
|
|
31
|
+
incompatibleDifferences: any[];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface ContentCanonicalizerResponse {
|
|
35
|
+
typedContent: any;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ContentCanonicalizerRequest {
|
|
39
|
+
content: any;
|
|
40
|
+
resolvedReferences: any[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ContentDereferencerResponse {
|
|
44
|
+
typedContent: any;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ContentValidatorResponse {
|
|
48
|
+
ruleViolations: any[];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface ReferenceFinderRequest {
|
|
52
|
+
typedContent: any;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ContentValidatorRequest {
|
|
56
|
+
level: string;
|
|
57
|
+
function: any;
|
|
58
|
+
content: any;
|
|
59
|
+
resolvedReferences: any[];
|
|
60
|
+
references: any[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface ReferenceFinderResponse {
|
|
64
|
+
externalReferences: any[];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface ContentDereferencerRequest {
|
|
68
|
+
content: any;
|
|
69
|
+
resolvedReferences: any[];
|
|
70
|
+
function: any;
|
|
71
|
+
resolvedReferenceUrls: any[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export interface CompatibilityCheckerRequest {
|
|
75
|
+
level: string;
|
|
76
|
+
existingArtifacts: any[];
|
|
77
|
+
proposedArtifact: any;
|
|
78
|
+
resolvedReferences: any[];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface ContentAccepterRequest {
|
|
82
|
+
typedContent: any;
|
|
83
|
+
resolvedReferences: any[];
|
|
84
|
+
}
|
|
85
|
+
|
package/package.json
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@apicurio/artifact-type-builtins",
|
|
3
|
+
"private": false,
|
|
4
|
+
"version": "3.1.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"description": "Built-in functions and TypeScript type definitions for creating custom artifact types in Apicurio Registry",
|
|
7
|
+
"main": "lib/ArtifactTypeScriptProvider_Builtins.mjs",
|
|
8
|
+
"types": "lib/ArtifactTypeScriptProvider_Builtins.d.ts",
|
|
9
|
+
"files": [
|
|
10
|
+
"lib"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"clean": "rimraf lib",
|
|
14
|
+
"copy-generated": "mkdir -p lib && cp ../app/target/classes/META-INF/quickjs4j/ArtifactTypeScriptProvider_Builtins.d.ts lib/ && cp ../app/target/classes/META-INF/quickjs4j/ArtifactTypeScriptProvider_Builtins.mjs lib/",
|
|
15
|
+
"build": "npm run clean && npm run copy-generated",
|
|
16
|
+
"prepublishOnly": "test -f lib/ArtifactTypeScriptProvider_Builtins.d.ts && test -f lib/ArtifactTypeScriptProvider_Builtins.mjs || (echo 'Error: Generated files not found. Run npm run build first.' && exit 1)"
|
|
17
|
+
},
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/Apicurio/apicurio-registry.git",
|
|
21
|
+
"directory": "artifact-type-builtins"
|
|
22
|
+
},
|
|
23
|
+
"keywords": [
|
|
24
|
+
"apicurio",
|
|
25
|
+
"registry",
|
|
26
|
+
"artifact-type",
|
|
27
|
+
"custom-artifact-type",
|
|
28
|
+
"typescript",
|
|
29
|
+
"quickjs"
|
|
30
|
+
],
|
|
31
|
+
"author": "Apicurio",
|
|
32
|
+
"license": "Apache-2.0",
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"rimraf": "6.0.1"
|
|
35
|
+
}
|
|
36
|
+
}
|