@azure/schema-registry-json 1.0.1-alpha.20250226.1 → 1.0.1-alpha.20250227.1
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 +37 -45
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -59,51 +59,45 @@ adapters for their message types.
|
|
|
59
59
|
|
|
60
60
|
### Serialize and deserialize an `@azure/event-hubs`'s `EventData`
|
|
61
61
|
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
// Example Json schema
|
|
79
|
-
const schema = JSON.stringify({
|
|
80
|
-
$schema: "http://json-schema.org/draft-04/schema#",
|
|
81
|
-
$id: "person",
|
|
82
|
-
title: "Student",
|
|
83
|
-
description: "A student in the class",
|
|
84
|
-
type: "object",
|
|
85
|
-
properties: {
|
|
86
|
-
name: {
|
|
87
|
-
type: "string",
|
|
88
|
-
description: "The name of the student",
|
|
89
|
-
},
|
|
90
|
-
},
|
|
91
|
-
required: ["name"],
|
|
92
|
-
});
|
|
62
|
+
```ts snippet:ReadmeSampleSerializeDeserialize
|
|
63
|
+
import { SchemaRegistryClient } from "@azure/schema-registry";
|
|
64
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
|
65
|
+
import { JsonSchemaSerializer } from "@azure/schema-registry-json";
|
|
66
|
+
import { createEventDataAdapter } from "@azure/event-hubs";
|
|
67
|
+
|
|
68
|
+
const client = new SchemaRegistryClient(
|
|
69
|
+
"<fully qualified namespace>",
|
|
70
|
+
new DefaultAzureCredential(),
|
|
71
|
+
);
|
|
72
|
+
const serializer = new JsonSchemaSerializer(client, {
|
|
73
|
+
groupName: "<group>",
|
|
74
|
+
messageAdapter: createEventDataAdapter(),
|
|
75
|
+
});
|
|
93
76
|
|
|
94
|
-
|
|
95
|
-
|
|
77
|
+
// Example Json schema
|
|
78
|
+
const schema = JSON.stringify({
|
|
79
|
+
$schema: "http://json-schema.org/draft-04/schema#",
|
|
80
|
+
$id: "person",
|
|
81
|
+
title: "Student",
|
|
82
|
+
description: "A student in the class",
|
|
83
|
+
type: "object",
|
|
84
|
+
properties: {
|
|
85
|
+
name: {
|
|
86
|
+
type: "string",
|
|
87
|
+
description: "The name of the student",
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
required: ["name"],
|
|
91
|
+
});
|
|
96
92
|
|
|
97
|
-
|
|
98
|
-
|
|
93
|
+
// Example value that matches the Json schema above
|
|
94
|
+
const value = { name: "Bob" };
|
|
99
95
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
96
|
+
// Serialize value to a message
|
|
97
|
+
const message = await serializer.serialize(value, schema);
|
|
103
98
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
});
|
|
99
|
+
// Deserialize a message to value
|
|
100
|
+
const deserializedValue = await serializer.deserialize(message);
|
|
107
101
|
```
|
|
108
102
|
|
|
109
103
|
The serializer doesn't check whether the deserialized value matches the schema
|
|
@@ -123,8 +117,8 @@ see a log of HTTP requests and responses, set the `AZURE_LOG_LEVEL` environment
|
|
|
123
117
|
variable to `info`. Alternatively, logging can be enabled at runtime by calling
|
|
124
118
|
`setLogLevel` in the `@azure/logger`:
|
|
125
119
|
|
|
126
|
-
```
|
|
127
|
-
|
|
120
|
+
```ts snippet:SetLogLevel
|
|
121
|
+
import { setLogLevel } from "@azure/logger";
|
|
128
122
|
|
|
129
123
|
setLogLevel("info");
|
|
130
124
|
```
|
|
@@ -162,8 +156,6 @@ learn more about how to build and test the code.
|
|
|
162
156
|
|
|
163
157
|
- [Microsoft Azure SDK for Javascript](https://github.com/Azure/azure-sdk-for-js)
|
|
164
158
|
|
|
165
|
-
|
|
166
|
-
|
|
167
159
|
[azure_cli]: https://learn.microsoft.com/cli/azure
|
|
168
160
|
[azure_sub]: https://azure.microsoft.com/free/
|
|
169
161
|
[azure_portal]: https://portal.azure.com
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azure/schema-registry-json",
|
|
3
|
-
"version": "1.0.1-alpha.
|
|
3
|
+
"version": "1.0.1-alpha.20250227.1",
|
|
4
4
|
"description": "Schema Registry JSON Serializer Library with typescript type definitions for node.js and browser.",
|
|
5
5
|
"sdk-type": "client",
|
|
6
6
|
"main": "./dist/commonjs/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
|
|
31
31
|
"unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser --no-test-proxy",
|
|
32
32
|
"unit-test:node": "dev-tool run test:vitest --no-test-proxy",
|
|
33
|
-
"update-snippets": "
|
|
33
|
+
"update-snippets": "dev-tool run update-snippets"
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"dist/",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
68
|
"dependencies": {
|
|
69
|
-
"@azure/logger": "^1.
|
|
69
|
+
"@azure/logger": "^1.1.4",
|
|
70
70
|
"@azure/schema-registry": "^1.3.0",
|
|
71
71
|
"lru-cache": "^10.2.0",
|
|
72
72
|
"tslib": "^2.8.1"
|
|
@@ -76,25 +76,26 @@
|
|
|
76
76
|
"@azure-tools/test-recorder": ">=4.1.0-alpha <4.1.0-alphb",
|
|
77
77
|
"@azure-tools/test-utils-vitest": ">=1.0.0-alpha <1.0.0-alphb",
|
|
78
78
|
"@azure-tools/vite-plugin-browser-test-map": ">=1.0.0-alpha <1.0.0-alphb",
|
|
79
|
-
"@azure/core-util": "^1.
|
|
79
|
+
"@azure/core-util": "^1.11.0",
|
|
80
80
|
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
|
81
81
|
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
|
82
82
|
"@azure/event-hubs": ">=6.0.0-alpha <6.0.0-alphb",
|
|
83
|
-
"@azure/identity": "^4.
|
|
83
|
+
"@azure/identity": "^4.7.0",
|
|
84
84
|
"@rollup/plugin-inject": "^5.0.5",
|
|
85
85
|
"@types/node": "^18.0.0",
|
|
86
|
-
"@vitest/browser": "^3.0.
|
|
87
|
-
"@vitest/coverage-istanbul": "^3.0.
|
|
86
|
+
"@vitest/browser": "^3.0.6",
|
|
87
|
+
"@vitest/coverage-istanbul": "^3.0.6",
|
|
88
88
|
"ajv": "^8.17.1",
|
|
89
89
|
"buffer": "^6.0.3",
|
|
90
90
|
"dotenv": "^16.0.0",
|
|
91
91
|
"eslint": "^9.9.0",
|
|
92
|
-
"playwright": "^1.
|
|
92
|
+
"playwright": "^1.50.1",
|
|
93
93
|
"typescript": "~5.7.2",
|
|
94
|
-
"vitest": "^3.0.
|
|
94
|
+
"vitest": "^3.0.6"
|
|
95
95
|
},
|
|
96
96
|
"type": "module",
|
|
97
97
|
"tshy": {
|
|
98
|
+
"project": "./tsconfig.src.json",
|
|
98
99
|
"exports": {
|
|
99
100
|
"./package.json": "./package.json",
|
|
100
101
|
".": "./src/index.ts"
|
|
@@ -107,8 +108,7 @@
|
|
|
107
108
|
"browser",
|
|
108
109
|
"react-native"
|
|
109
110
|
],
|
|
110
|
-
"selfLink": false
|
|
111
|
-
"project": "./tsconfig.src.json"
|
|
111
|
+
"selfLink": false
|
|
112
112
|
},
|
|
113
113
|
"browser": "./dist/browser/index.js",
|
|
114
114
|
"exports": {
|
|
@@ -131,5 +131,6 @@
|
|
|
131
131
|
"default": "./dist/commonjs/index.js"
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
}
|
|
134
|
+
},
|
|
135
|
+
"react-native": "./dist/react-native/index.js"
|
|
135
136
|
}
|