@scalar/types 0.1.16 → 0.2.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,318 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
- import {
3
- oasSecurityRequirementSchema,
4
- pkceOptions,
5
- securityApiKeySchema,
6
- securityHttpSchema,
7
- securityOauthSchema,
8
- securityOpenIdSchema,
9
- securitySchemeSchema
10
- } from "./security-scheme.js";
11
- describe("Security Schemas", () => {
12
- describe("API Key Schema", () => {
13
- it("should validate a valid API key schema", () => {
14
- const apiKey = {
15
- type: "apiKey",
16
- name: "api_key",
17
- in: "header",
18
- description: "API Key Authentication",
19
- uid: "apikey123",
20
- nameKey: "x-api-key",
21
- value: "test-api-key"
22
- };
23
- const result = securityApiKeySchema.safeParse(apiKey);
24
- expect(result.success).toBe(true);
25
- });
26
- it("should apply default values", () => {
27
- const minimalApiKey = {
28
- type: "apiKey",
29
- uid: "apikey123"
30
- };
31
- const result = securityApiKeySchema.parse(minimalApiKey);
32
- expect(result).toEqual({
33
- type: "apiKey",
34
- uid: "apikey123",
35
- name: "",
36
- in: "header",
37
- nameKey: "",
38
- value: ""
39
- });
40
- });
41
- });
42
- describe("HTTP Schema", () => {
43
- it("should validate a valid HTTP basic schema", () => {
44
- const httpBasic = {
45
- type: "http",
46
- scheme: "basic",
47
- description: "Basic HTTP Authentication",
48
- uid: "http123",
49
- username: "user",
50
- password: "pass"
51
- };
52
- const result = securityHttpSchema.safeParse(httpBasic);
53
- expect(result.success).toBe(true);
54
- });
55
- it("should validate a valid HTTP bearer schema", () => {
56
- const httpBearer = {
57
- type: "http",
58
- scheme: "bearer",
59
- bearerFormat: "JWT",
60
- description: "Bearer Authentication",
61
- uid: "http456",
62
- token: "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9"
63
- };
64
- const result = securityHttpSchema.safeParse(httpBearer);
65
- expect(result.success).toBe(true);
66
- });
67
- it("should apply default values", () => {
68
- const minimalHttp = {
69
- type: "http",
70
- uid: "http123"
71
- };
72
- const result = securityHttpSchema.parse(minimalHttp);
73
- expect(result).toEqual({
74
- type: "http",
75
- uid: "http123",
76
- scheme: "basic",
77
- bearerFormat: "JWT",
78
- nameKey: "",
79
- username: "",
80
- password: "",
81
- token: ""
82
- });
83
- });
84
- it("should reject invalid scheme values", () => {
85
- const invalidHttp = {
86
- type: "http",
87
- scheme: "digest",
88
- uid: "http123"
89
- };
90
- const result = securityHttpSchema.safeParse(invalidHttp);
91
- expect(result.success).toBe(false);
92
- });
93
- });
94
- describe("OpenID Connect Schema", () => {
95
- it("should validate a valid OpenID schema", () => {
96
- const openId = {
97
- type: "openIdConnect",
98
- openIdConnectUrl: "https://example.com/.well-known/openid-configuration",
99
- description: "OpenID Connect",
100
- uid: "openid123",
101
- nameKey: "openid"
102
- };
103
- const result = securityOpenIdSchema.safeParse(openId);
104
- expect(result.success).toBe(true);
105
- });
106
- it("should apply default values", () => {
107
- const minimalOpenId = {
108
- type: "openIdConnect",
109
- uid: "openid123"
110
- };
111
- const result = securityOpenIdSchema.parse(minimalOpenId);
112
- expect(result).toEqual({
113
- type: "openIdConnect",
114
- uid: "openid123",
115
- openIdConnectUrl: "",
116
- nameKey: ""
117
- });
118
- });
119
- });
120
- describe("OAuth2 Schema", () => {
121
- it("should validate a valid OAuth2 implicit flow schema", () => {
122
- const oauth2Implicit = {
123
- type: "oauth2",
124
- description: "OAuth2 Implicit Flow",
125
- uid: "oauth123",
126
- flows: {
127
- implicit: {
128
- type: "implicit",
129
- authorizationUrl: "https://example.com/oauth/authorize",
130
- scopes: {
131
- "read:api": "Read access",
132
- "write:api": "Write access"
133
- },
134
- selectedScopes: ["read:api"],
135
- token: "access-token-123"
136
- }
137
- }
138
- };
139
- const result = securityOauthSchema.safeParse(oauth2Implicit);
140
- expect(result.success).toBe(true);
141
- });
142
- it("should validate a valid OAuth2 with missing scopes", () => {
143
- const oauth2Implicit = {
144
- type: "oauth2",
145
- description: "OAuth2 Implicit Flow",
146
- uid: "oauth123",
147
- flows: {
148
- implicit: {
149
- type: "implicit",
150
- authorizationUrl: "https://example.com/oauth/authorize",
151
- scopes: null,
152
- selectedScopes: ["read:api"],
153
- token: "access-token-123"
154
- }
155
- }
156
- };
157
- const result = securityOauthSchema.safeParse(oauth2Implicit);
158
- expect(result.success).toBe(true);
159
- });
160
- it("should validate a valid OAuth2 authorization code flow schema", () => {
161
- const oauth2AuthCode = {
162
- type: "oauth2",
163
- description: "OAuth2 Authorization Code Flow",
164
- uid: "oauth456",
165
- flows: {
166
- authorizationCode: {
167
- type: "authorizationCode",
168
- authorizationUrl: "https://example.com/oauth/authorize",
169
- tokenUrl: "https://example.com/oauth/token",
170
- "x-usePkce": "SHA-256",
171
- scopes: {
172
- "read:api": "Read access",
173
- "write:api": "Write access"
174
- },
175
- clientSecret: "client-secret",
176
- token: "access-token-456",
177
- "x-scalar-security-query": {
178
- prompt: "consent"
179
- }
180
- }
181
- }
182
- };
183
- const result = securityOauthSchema.safeParse(oauth2AuthCode);
184
- expect(result.success).toBe(true);
185
- });
186
- it("should validate a valid OAuth2 client credentials flow schema", () => {
187
- const oauth2ClientCreds = {
188
- type: "oauth2",
189
- description: "OAuth2 Client Credentials Flow",
190
- uid: "oauth789",
191
- flows: {
192
- clientCredentials: {
193
- type: "clientCredentials",
194
- tokenUrl: "https://example.com/oauth/token",
195
- scopes: {},
196
- clientSecret: "client-secret",
197
- token: "access-token-789"
198
- }
199
- }
200
- };
201
- const result = securityOauthSchema.safeParse(oauth2ClientCreds);
202
- expect(result.success).toBe(true);
203
- });
204
- it("should validate a valid OAuth2 password flow schema", () => {
205
- const oauth2Password = {
206
- type: "oauth2",
207
- description: "OAuth2 Password Flow",
208
- uid: "oauth101",
209
- flows: {
210
- password: {
211
- type: "password",
212
- tokenUrl: "https://example.com/oauth/token",
213
- scopes: {},
214
- username: "testuser",
215
- password: "testpass",
216
- clientSecret: "client-secret",
217
- token: "access-token-101",
218
- "x-scalar-security-query": {
219
- prompt: "consent",
220
- audience: "scalar"
221
- }
222
- }
223
- }
224
- };
225
- const result = securityOauthSchema.safeParse(oauth2Password);
226
- expect(result.success).toBe(true);
227
- });
228
- it("should apply default values", () => {
229
- const minimalOauth2 = {
230
- type: "oauth2",
231
- uid: "oauth123"
232
- };
233
- const result = securityOauthSchema.parse(minimalOauth2);
234
- expect(result.flows.implicit).toBeDefined();
235
- expect(result.flows.implicit?.authorizationUrl).toBe("http://localhost:8080");
236
- expect(result.flows.implicit?.scopes).toEqual({});
237
- expect(result.flows.implicit?.selectedScopes).toEqual([]);
238
- expect(result.flows.implicit?.token).toBe("");
239
- expect(result.nameKey).toBe("");
240
- });
241
- it("should validate PKCE options", () => {
242
- expect(pkceOptions).toContain("SHA-256");
243
- expect(pkceOptions).toContain("plain");
244
- expect(pkceOptions).toContain("no");
245
- });
246
- it("should apply x-default-scopes", () => {
247
- const oauth2 = {
248
- type: "oauth2",
249
- uid: "oauth123",
250
- "x-default-scopes": ["read:api", "write:api"]
251
- };
252
- const result = securitySchemeSchema.parse(oauth2);
253
- if (result.type !== "oauth2") {
254
- throw new Error("Expected oauth2 schema");
255
- }
256
- expect(result["x-default-scopes"]).toEqual(["read:api", "write:api"]);
257
- expect(result.flows.implicit?.selectedScopes).toEqual(["read:api", "write:api"]);
258
- });
259
- });
260
- describe("Security Requirement Schema", () => {
261
- it("should validate a valid security requirement", () => {
262
- const securityRequirement = {
263
- "api_key": [],
264
- "oauth2": ["read:api", "write:api"]
265
- };
266
- const result = oasSecurityRequirementSchema.safeParse(securityRequirement);
267
- expect(result.success).toBe(true);
268
- });
269
- it("should apply default values for empty scopes", () => {
270
- const securityRequirement = {
271
- "api_key": void 0
272
- };
273
- const result = oasSecurityRequirementSchema.parse(securityRequirement);
274
- expect(result).toEqual({
275
- "api_key": []
276
- });
277
- });
278
- });
279
- describe("Combined Security Scheme", () => {
280
- it("should validate all security scheme types", () => {
281
- const apiKey = {
282
- type: "apiKey",
283
- name: "api_key",
284
- in: "header",
285
- uid: "apikey123",
286
- value: "test-api-key"
287
- };
288
- const http = {
289
- type: "http",
290
- scheme: "bearer",
291
- uid: "http123",
292
- token: "bearer-token"
293
- };
294
- const openId = {
295
- type: "openIdConnect",
296
- openIdConnectUrl: "https://example.com/.well-known/openid-configuration",
297
- uid: "openid123"
298
- };
299
- const oauth2 = {
300
- type: "oauth2",
301
- uid: "oauth123",
302
- flows: {
303
- implicit: {
304
- type: "implicit",
305
- authorizationUrl: "https://example.com/oauth/authorize",
306
- scopes: {},
307
- token: ""
308
- }
309
- }
310
- };
311
- expect(securitySchemeSchema.safeParse(apiKey).success).toBe(true);
312
- expect(securitySchemeSchema.safeParse(http).success).toBe(true);
313
- expect(securitySchemeSchema.safeParse(openId).success).toBe(true);
314
- expect(securitySchemeSchema.safeParse(oauth2).success).toBe(true);
315
- });
316
- });
317
- });
318
- //# sourceMappingURL=security-scheme.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/entities/security-scheme.test.ts"],
4
- "sourcesContent": ["import { describe, expect, it } from 'vitest'\nimport {\n oasSecurityRequirementSchema,\n pkceOptions,\n securityApiKeySchema,\n securityHttpSchema,\n securityOauthSchema,\n securityOpenIdSchema,\n securitySchemeSchema,\n} from './security-scheme'\n\ndescribe('Security Schemas', () => {\n describe('API Key Schema', () => {\n it('should validate a valid API key schema', () => {\n const apiKey = {\n type: 'apiKey',\n name: 'api_key',\n in: 'header',\n description: 'API Key Authentication',\n uid: 'apikey123',\n nameKey: 'x-api-key',\n value: 'test-api-key',\n }\n\n const result = securityApiKeySchema.safeParse(apiKey)\n expect(result.success).toBe(true)\n })\n\n it('should apply default values', () => {\n const minimalApiKey = {\n type: 'apiKey',\n uid: 'apikey123',\n }\n\n const result = securityApiKeySchema.parse(minimalApiKey)\n expect(result).toEqual({\n type: 'apiKey',\n uid: 'apikey123',\n name: '',\n in: 'header',\n nameKey: '',\n value: '',\n })\n })\n })\n\n describe('HTTP Schema', () => {\n it('should validate a valid HTTP basic schema', () => {\n const httpBasic = {\n type: 'http',\n scheme: 'basic',\n description: 'Basic HTTP Authentication',\n uid: 'http123',\n username: 'user',\n password: 'pass',\n }\n\n const result = securityHttpSchema.safeParse(httpBasic)\n expect(result.success).toBe(true)\n })\n\n it('should validate a valid HTTP bearer schema', () => {\n const httpBearer = {\n type: 'http',\n scheme: 'bearer',\n bearerFormat: 'JWT',\n description: 'Bearer Authentication',\n uid: 'http456',\n token: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9',\n }\n\n const result = securityHttpSchema.safeParse(httpBearer)\n expect(result.success).toBe(true)\n })\n\n it('should apply default values', () => {\n const minimalHttp = {\n type: 'http',\n uid: 'http123',\n }\n\n const result = securityHttpSchema.parse(minimalHttp)\n expect(result).toEqual({\n type: 'http',\n uid: 'http123',\n scheme: 'basic',\n bearerFormat: 'JWT',\n nameKey: '',\n username: '',\n password: '',\n token: '',\n })\n })\n\n it('should reject invalid scheme values', () => {\n const invalidHttp = {\n type: 'http',\n scheme: 'digest',\n uid: 'http123',\n }\n\n const result = securityHttpSchema.safeParse(invalidHttp)\n expect(result.success).toBe(false)\n })\n })\n\n describe('OpenID Connect Schema', () => {\n it('should validate a valid OpenID schema', () => {\n const openId = {\n type: 'openIdConnect',\n openIdConnectUrl: 'https://example.com/.well-known/openid-configuration',\n description: 'OpenID Connect',\n uid: 'openid123',\n nameKey: 'openid',\n }\n\n const result = securityOpenIdSchema.safeParse(openId)\n expect(result.success).toBe(true)\n })\n\n it('should apply default values', () => {\n const minimalOpenId = {\n type: 'openIdConnect',\n uid: 'openid123',\n }\n\n const result = securityOpenIdSchema.parse(minimalOpenId)\n expect(result).toEqual({\n type: 'openIdConnect',\n uid: 'openid123',\n openIdConnectUrl: '',\n nameKey: '',\n })\n })\n })\n\n describe('OAuth2 Schema', () => {\n it('should validate a valid OAuth2 implicit flow schema', () => {\n const oauth2Implicit = {\n type: 'oauth2',\n description: 'OAuth2 Implicit Flow',\n uid: 'oauth123',\n flows: {\n implicit: {\n type: 'implicit',\n authorizationUrl: 'https://example.com/oauth/authorize',\n scopes: {\n 'read:api': 'Read access',\n 'write:api': 'Write access',\n },\n selectedScopes: ['read:api'],\n token: 'access-token-123',\n },\n },\n }\n\n const result = securityOauthSchema.safeParse(oauth2Implicit)\n expect(result.success).toBe(true)\n })\n\n it('should validate a valid OAuth2 with missing scopes', () => {\n const oauth2Implicit = {\n type: 'oauth2',\n description: 'OAuth2 Implicit Flow',\n uid: 'oauth123',\n flows: {\n implicit: {\n type: 'implicit',\n authorizationUrl: 'https://example.com/oauth/authorize',\n scopes: null,\n selectedScopes: ['read:api'],\n token: 'access-token-123',\n },\n },\n }\n\n const result = securityOauthSchema.safeParse(oauth2Implicit)\n expect(result.success).toBe(true)\n })\n\n it('should validate a valid OAuth2 authorization code flow schema', () => {\n const oauth2AuthCode = {\n type: 'oauth2',\n description: 'OAuth2 Authorization Code Flow',\n uid: 'oauth456',\n flows: {\n authorizationCode: {\n type: 'authorizationCode',\n authorizationUrl: 'https://example.com/oauth/authorize',\n tokenUrl: 'https://example.com/oauth/token',\n 'x-usePkce': 'SHA-256',\n scopes: {\n 'read:api': 'Read access',\n 'write:api': 'Write access',\n },\n clientSecret: 'client-secret',\n token: 'access-token-456',\n 'x-scalar-security-query': {\n prompt: 'consent',\n },\n },\n },\n }\n\n const result = securityOauthSchema.safeParse(oauth2AuthCode)\n expect(result.success).toBe(true)\n })\n\n it('should validate a valid OAuth2 client credentials flow schema', () => {\n const oauth2ClientCreds = {\n type: 'oauth2',\n description: 'OAuth2 Client Credentials Flow',\n uid: 'oauth789',\n flows: {\n clientCredentials: {\n type: 'clientCredentials',\n tokenUrl: 'https://example.com/oauth/token',\n scopes: {},\n clientSecret: 'client-secret',\n token: 'access-token-789',\n },\n },\n }\n\n const result = securityOauthSchema.safeParse(oauth2ClientCreds)\n expect(result.success).toBe(true)\n })\n\n it('should validate a valid OAuth2 password flow schema', () => {\n const oauth2Password = {\n type: 'oauth2',\n description: 'OAuth2 Password Flow',\n uid: 'oauth101',\n flows: {\n password: {\n type: 'password',\n tokenUrl: 'https://example.com/oauth/token',\n scopes: {},\n username: 'testuser',\n password: 'testpass',\n clientSecret: 'client-secret',\n token: 'access-token-101',\n 'x-scalar-security-query': {\n prompt: 'consent',\n audience: 'scalar',\n },\n },\n },\n }\n\n const result = securityOauthSchema.safeParse(oauth2Password)\n expect(result.success).toBe(true)\n })\n\n it('should apply default values', () => {\n const minimalOauth2 = {\n type: 'oauth2',\n uid: 'oauth123',\n }\n\n const result = securityOauthSchema.parse(minimalOauth2)\n expect(result.flows.implicit).toBeDefined()\n expect(result.flows.implicit?.authorizationUrl).toBe('http://localhost:8080')\n expect(result.flows.implicit?.scopes).toEqual({})\n expect(result.flows.implicit?.selectedScopes).toEqual([])\n expect(result.flows.implicit?.token).toBe('')\n expect(result.nameKey).toBe('')\n })\n\n it('should validate PKCE options', () => {\n expect(pkceOptions).toContain('SHA-256')\n expect(pkceOptions).toContain('plain')\n expect(pkceOptions).toContain('no')\n })\n\n it('should apply x-default-scopes', () => {\n const oauth2 = {\n type: 'oauth2',\n uid: 'oauth123',\n 'x-default-scopes': ['read:api', 'write:api'],\n }\n\n const result = securitySchemeSchema.parse(oauth2)\n if (result.type !== 'oauth2') {\n throw new Error('Expected oauth2 schema')\n }\n expect(result['x-default-scopes']).toEqual(['read:api', 'write:api'])\n expect(result.flows.implicit?.selectedScopes).toEqual(['read:api', 'write:api'])\n })\n })\n\n describe('Security Requirement Schema', () => {\n it('should validate a valid security requirement', () => {\n const securityRequirement = {\n 'api_key': [],\n 'oauth2': ['read:api', 'write:api'],\n }\n\n const result = oasSecurityRequirementSchema.safeParse(securityRequirement)\n expect(result.success).toBe(true)\n })\n\n it('should apply default values for empty scopes', () => {\n const securityRequirement = {\n 'api_key': undefined,\n }\n\n const result = oasSecurityRequirementSchema.parse(securityRequirement)\n expect(result).toEqual({\n 'api_key': [],\n })\n })\n })\n\n describe('Combined Security Scheme', () => {\n it('should validate all security scheme types', () => {\n const apiKey = {\n type: 'apiKey',\n name: 'api_key',\n in: 'header',\n uid: 'apikey123',\n value: 'test-api-key',\n }\n\n const http = {\n type: 'http',\n scheme: 'bearer',\n uid: 'http123',\n token: 'bearer-token',\n }\n\n const openId = {\n type: 'openIdConnect',\n openIdConnectUrl: 'https://example.com/.well-known/openid-configuration',\n uid: 'openid123',\n }\n\n const oauth2 = {\n type: 'oauth2',\n uid: 'oauth123',\n flows: {\n implicit: {\n type: 'implicit',\n authorizationUrl: 'https://example.com/oauth/authorize',\n scopes: {},\n token: '',\n },\n },\n }\n\n expect(securitySchemeSchema.safeParse(apiKey).success).toBe(true)\n expect(securitySchemeSchema.safeParse(http).success).toBe(true)\n expect(securitySchemeSchema.safeParse(openId).success).toBe(true)\n expect(securitySchemeSchema.safeParse(oauth2).success).toBe(true)\n })\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,QAAQ,UAAU;AACrC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP,SAAS,oBAAoB,MAAM;AACjC,WAAS,kBAAkB,MAAM;AAC/B,OAAG,0CAA0C,MAAM;AACjD,YAAM,SAAS;AAAA,QACb,MAAM;AAAA,QACN,MAAM;AAAA,QACN,IAAI;AAAA,QACJ,aAAa;AAAA,QACb,KAAK;AAAA,QACL,SAAS;AAAA,QACT,OAAO;AAAA,MACT;AAEA,YAAM,SAAS,qBAAqB,UAAU,MAAM;AACpD,aAAO,OAAO,OAAO,EAAE,KAAK,IAAI;AAAA,IAClC,CAAC;AAED,OAAG,+BAA+B,MAAM;AACtC,YAAM,gBAAgB;AAAA,QACpB,MAAM;AAAA,QACN,KAAK;AAAA,MACP;AAEA,YAAM,SAAS,qBAAqB,MAAM,aAAa;AACvD,aAAO,MAAM,EAAE,QAAQ;AAAA,QACrB,MAAM;AAAA,QACN,KAAK;AAAA,QACL,MAAM;AA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AK,IAAI;AAAA,IAClE,CAAC;AAAA,EACH,CAAC;AACH,CAAC;",
6
- "names": []
7
- }
@@ -1,29 +0,0 @@
1
- import { describe, it, expect } from "vitest";
2
- import { nanoidSchema } from "./nanoid.js";
3
- import { z } from "zod";
4
- describe("nanoidSchema", () => {
5
- it("should generate a string with minimum length of 7 characters when no value is provided", () => {
6
- const result = nanoidSchema.parse(void 0);
7
- expect(typeof result).toBe("string");
8
- expect(result.length).toBeGreaterThanOrEqual(7);
9
- });
10
- it("should accept valid strings with length >= 7", () => {
11
- const validString = "1234567";
12
- const result = nanoidSchema.parse(validString);
13
- expect(result).toBe(validString);
14
- });
15
- it("should reject strings shorter than 7 characters", () => {
16
- const invalidString = "123456";
17
- expect(() => nanoidSchema.parse(invalidString)).toThrow(z.ZodError);
18
- });
19
- it("should generate different IDs for multiple calls", () => {
20
- const id1 = nanoidSchema.parse(void 0);
21
- const id2 = nanoidSchema.parse(void 0);
22
- expect(id1).not.toBe(id2);
23
- });
24
- it("should properly type the generated ID as Nanoid", () => {
25
- const id = nanoidSchema.parse(void 0);
26
- expect(typeof id).toBe("string");
27
- });
28
- });
29
- //# sourceMappingURL=nanoid.test.js.map
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../src/utils/nanoid.test.ts"],
4
- "sourcesContent": ["import { describe, it, expect } from 'vitest'\nimport { nanoidSchema, type Nanoid } from './nanoid'\nimport { z } from 'zod'\n\ndescribe('nanoidSchema', () => {\n it('should generate a string with minimum length of 7 characters when no value is provided', () => {\n const result = nanoidSchema.parse(undefined)\n expect(typeof result).toBe('string')\n expect(result.length).toBeGreaterThanOrEqual(7)\n })\n\n it('should accept valid strings with length >= 7', () => {\n const validString = '1234567'\n const result = nanoidSchema.parse(validString)\n expect(result).toBe(validString)\n })\n\n it('should reject strings shorter than 7 characters', () => {\n const invalidString = '123456'\n expect(() => nanoidSchema.parse(invalidString)).toThrow(z.ZodError)\n })\n\n it('should generate different IDs for multiple calls', () => {\n const id1 = nanoidSchema.parse(undefined)\n const id2 = nanoidSchema.parse(undefined)\n expect(id1).not.toBe(id2)\n })\n\n it('should properly type the generated ID as Nanoid', () => {\n const id: Nanoid = nanoidSchema.parse(undefined)\n expect(typeof id).toBe('string')\n })\n})\n"],
5
- "mappings": "AAAA,SAAS,UAAU,IAAI,cAAc;AACrC,SAAS,oBAAiC;AAC1C,SAAS,SAAS;AAElB,SAAS,gBAAgB,MAAM;AAC7B,KAAG,0FAA0F,MAAM;AACjG,UAAM,SAAS,aAAa,MAAM,MAAS;AAC3C,WAAO,OAAO,MAAM,EAAE,KAAK,QAAQ;AACnC,WAAO,OAAO,MAAM,EAAE,uBAAuB,CAAC;AAAA,EAChD,CAAC;AAED,KAAG,gDAAgD,MAAM;AACvD,UAAM,cAAc;AACpB,UAAM,SAAS,aAAa,MAAM,WAAW;AAC7C,WAAO,MAAM,EAAE,KAAK,WAAW;AAAA,EACjC,CAAC;AAED,KAAG,mDAAmD,MAAM;AAC1D,UAAM,gBAAgB;AACtB,WAAO,MAAM,aAAa,MAAM,aAAa,CAAC,EAAE,QAAQ,EAAE,QAAQ;AAAA,EACpE,CAAC;AAED,KAAG,oDAAoD,MAAM;AAC3D,UAAM,MAAM,aAAa,MAAM,MAAS;AACxC,UAAM,MAAM,aAAa,MAAM,MAAS;AACxC,WAAO,GAAG,EAAE,IAAI,KAAK,GAAG;AAAA,EAC1B,CAAC;AAED,KAAG,mDAAmD,MAAM;AAC1D,UAAM,KAAa,aAAa,MAAM,MAAS;AAC/C,WAAO,OAAO,EAAE,EAAE,KAAK,QAAQ;AAAA,EACjC,CAAC;AACH,CAAC;",
6
- "names": []
7
- }