@unispechq/unispec-core 0.1.1 → 0.1.2

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.
@@ -1,115 +0,0 @@
1
- import test from "node:test";
2
- import assert from "node:assert/strict";
3
-
4
- import * as core from "../dist/index.js";
5
-
6
- const { normalizeUniSpec } = core;
7
-
8
- test("normalizeUniSpec sorts object keys deterministically", () => {
9
- const doc = {
10
- b: 1,
11
- a: {
12
- d: 3,
13
- c: 2,
14
- },
15
- };
16
-
17
- const normalized = normalizeUniSpec(doc);
18
-
19
- assert.deepEqual(Object.keys(normalized), ["a", "b"]);
20
- assert.deepEqual(Object.keys(normalized.a), ["c", "d"]);
21
- });
22
-
23
- test("normalizeUniSpec normalizes REST paths and HTTP methods order", () => {
24
- const doc = {
25
- unispecVersion: "0.1.0",
26
- service: {
27
- name: "test-service",
28
- protocols: {
29
- rest: {
30
- paths: {
31
- "/z": {
32
- post: {},
33
- get: {},
34
- },
35
- "/a": {
36
- delete: {},
37
- get: {},
38
- },
39
- },
40
- },
41
- },
42
- },
43
- };
44
-
45
- const normalized = normalizeUniSpec(doc);
46
-
47
- const paths = normalized.service.protocols.rest.paths;
48
-
49
- assert.deepEqual(Object.keys(paths), ["/a", "/z"]);
50
- assert.deepEqual(Object.keys(paths["/z"]), ["get", "post"]);
51
- assert.deepEqual(Object.keys(paths["/a"]), ["get", "delete"]);
52
- });
53
-
54
- test("normalizeUniSpec normalizes GraphQL operations order", () => {
55
- const doc = {
56
- unispecVersion: "0.1.0",
57
- service: {
58
- name: "test-service",
59
- protocols: {
60
- graphql: {
61
- operations: {
62
- queries: {
63
- me: {},
64
- ping: {},
65
- a: {},
66
- },
67
- },
68
- },
69
- },
70
- },
71
- };
72
-
73
- const normalized = normalizeUniSpec(doc);
74
-
75
- const queries = normalized.service.protocols.graphql.operations.queries;
76
- assert.deepEqual(Object.keys(queries), ["a", "me", "ping"]);
77
- });
78
-
79
- test("normalizeUniSpec normalizes WebSocket channels and messages order", () => {
80
- const doc = {
81
- unispecVersion: "0.1.0",
82
- service: {
83
- name: "test-service",
84
- protocols: {
85
- websocket: {
86
- channels: {
87
- zChannel: {
88
- messages: [
89
- { name: "msgB" },
90
- { name: "msgA" },
91
- ],
92
- },
93
- aChannel: {
94
- messages: [
95
- { name: "z" },
96
- { name: "a" },
97
- ],
98
- },
99
- },
100
- },
101
- },
102
- },
103
- };
104
-
105
- const normalized = normalizeUniSpec(doc);
106
-
107
- const channels = normalized.service.protocols.websocket.channels;
108
- assert.deepEqual(Object.keys(channels), ["aChannel", "zChannel"]);
109
-
110
- const aMessages = channels.aChannel.messages;
111
- const zMessages = channels.zChannel.messages;
112
-
113
- assert.deepEqual(aMessages.map((m) => m.name), ["a", "z"]);
114
- assert.deepEqual(zMessages.map((m) => m.name), ["msgA", "msgB"]);
115
- });
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "moduleResolution": "Node",
6
- "outDir": "dist",
7
- "rootDir": "src",
8
- "declaration": true,
9
- "strict": true,
10
- "esModuleInterop": true,
11
- "forceConsistentCasingInFileNames": true,
12
- "skipLibCheck": true
13
- },
14
- "include": ["src"]
15
- }
File without changes