@vrplatform/api 1.3.1-preview.4563 → 1.3.1-preview.6162

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.
Files changed (39) hide show
  1. package/build/main/embed-lifecycle.d.ts +140 -0
  2. package/build/main/embed-lifecycle.js +93 -0
  3. package/build/main/embed-lifecycle.js.map +1 -0
  4. package/build/main/error.d.ts +1 -1
  5. package/build/main/error.js.map +1 -1
  6. package/build/main/generated/v1.d.ts +24645 -13598
  7. package/build/main/generated/v1.js.map +1 -1
  8. package/build/main/index.d.ts +1 -0
  9. package/build/main/index.js +1 -0
  10. package/build/main/index.js.map +1 -1
  11. package/build/main/routing.d.ts +5 -0
  12. package/build/main/routing.js +22 -0
  13. package/build/main/routing.js.map +1 -1
  14. package/build/module/embed-lifecycle.d.ts +140 -0
  15. package/build/module/embed-lifecycle.js +90 -0
  16. package/build/module/embed-lifecycle.js.map +1 -0
  17. package/build/module/error.d.ts +1 -1
  18. package/build/module/error.js.map +1 -1
  19. package/build/module/generated/v1.d.ts +24645 -13598
  20. package/build/module/generated/v1.js.map +1 -1
  21. package/build/module/index.d.ts +1 -0
  22. package/build/module/index.js +1 -0
  23. package/build/module/index.js.map +1 -1
  24. package/build/module/routing.d.ts +5 -0
  25. package/build/module/routing.js +21 -0
  26. package/build/module/routing.js.map +1 -1
  27. package/package.json +3 -3
  28. package/src/embed-lifecycle.ts +96 -0
  29. package/src/error.ts +1 -1
  30. package/src/generated/v1.ts +24645 -13598
  31. package/src/index.ts +1 -0
  32. package/src/routing.ts +30 -0
  33. package/build/main/generated/openapi-fetch.d.ts +0 -224
  34. package/build/main/generated/openapi-fetch.js +0 -14
  35. package/build/main/generated/openapi-fetch.js.map +0 -1
  36. package/build/module/generated/openapi-fetch.d.ts +0 -224
  37. package/build/module/generated/openapi-fetch.js +0 -2
  38. package/build/module/generated/openapi-fetch.js.map +0 -1
  39. package/src/generated/openapi-fetch.ts +0 -433
@@ -0,0 +1,140 @@
1
+ import { z } from 'zod';
2
+ declare const channelRequestSchema: z.ZodObject<{
3
+ requestId: z.ZodUUID;
4
+ type: z.ZodLiteral<"channel.request">;
5
+ channelId: z.ZodUUID;
6
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
7
+ version: z.ZodLiteral<1>;
8
+ }, z.core.$strict>;
9
+ declare const channelConnectSchema: z.ZodObject<{
10
+ replyTo: z.ZodUUID;
11
+ type: z.ZodLiteral<"channel.connect">;
12
+ channelId: z.ZodUUID;
13
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
14
+ version: z.ZodLiteral<1>;
15
+ }, z.core.$strict>;
16
+ declare const iframeMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
17
+ type: z.ZodLiteral<"ready">;
18
+ channelId: z.ZodUUID;
19
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
20
+ version: z.ZodLiteral<1>;
21
+ }, z.core.$strict>, z.ZodObject<{
22
+ code: z.ZodEnum<{
23
+ authentication_failed: "authentication_failed";
24
+ access_denied: "access_denied";
25
+ session_expired: "session_expired";
26
+ renewal_failed: "renewal_failed";
27
+ unsupported_version: "unsupported_version";
28
+ internal_error: "internal_error";
29
+ }>;
30
+ correlationId: z.ZodString;
31
+ recoverable: z.ZodBoolean;
32
+ replyTo: z.ZodOptional<z.ZodUUID>;
33
+ type: z.ZodLiteral<"error">;
34
+ channelId: z.ZodUUID;
35
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
36
+ version: z.ZodLiteral<1>;
37
+ }, z.core.$strict>, z.ZodObject<{
38
+ expiresAt: z.ZodISODateTime;
39
+ requestId: z.ZodUUID;
40
+ type: z.ZodLiteral<"session.expiring">;
41
+ channelId: z.ZodUUID;
42
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
43
+ version: z.ZodLiteral<1>;
44
+ }, z.core.$strict>, z.ZodObject<{
45
+ expiresAt: z.ZodISODateTime;
46
+ replyTo: z.ZodUUID;
47
+ type: z.ZodLiteral<"session.renewed">;
48
+ channelId: z.ZodUUID;
49
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
50
+ version: z.ZodLiteral<1>;
51
+ }, z.core.$strict>, z.ZodObject<{
52
+ height: z.ZodNumber;
53
+ type: z.ZodLiteral<"resize">;
54
+ channelId: z.ZodUUID;
55
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
56
+ version: z.ZodLiteral<1>;
57
+ }, z.core.$strict>], "type">;
58
+ declare const parentMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
59
+ embedUrl: z.ZodURL;
60
+ replyTo: z.ZodUUID;
61
+ requestId: z.ZodUUID;
62
+ type: z.ZodLiteral<"session.renew">;
63
+ channelId: z.ZodUUID;
64
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
65
+ version: z.ZodLiteral<1>;
66
+ }, z.core.$strict>], "type">;
67
+ export declare const embedLifecycle: {
68
+ readonly channelConnectSchema: z.ZodObject<{
69
+ replyTo: z.ZodUUID;
70
+ type: z.ZodLiteral<"channel.connect">;
71
+ channelId: z.ZodUUID;
72
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
73
+ version: z.ZodLiteral<1>;
74
+ }, z.core.$strict>;
75
+ readonly channelRequestSchema: z.ZodObject<{
76
+ requestId: z.ZodUUID;
77
+ type: z.ZodLiteral<"channel.request">;
78
+ channelId: z.ZodUUID;
79
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
80
+ version: z.ZodLiteral<1>;
81
+ }, z.core.$strict>;
82
+ readonly iframeMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
83
+ type: z.ZodLiteral<"ready">;
84
+ channelId: z.ZodUUID;
85
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
86
+ version: z.ZodLiteral<1>;
87
+ }, z.core.$strict>, z.ZodObject<{
88
+ code: z.ZodEnum<{
89
+ authentication_failed: "authentication_failed";
90
+ access_denied: "access_denied";
91
+ session_expired: "session_expired";
92
+ renewal_failed: "renewal_failed";
93
+ unsupported_version: "unsupported_version";
94
+ internal_error: "internal_error";
95
+ }>;
96
+ correlationId: z.ZodString;
97
+ recoverable: z.ZodBoolean;
98
+ replyTo: z.ZodOptional<z.ZodUUID>;
99
+ type: z.ZodLiteral<"error">;
100
+ channelId: z.ZodUUID;
101
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
102
+ version: z.ZodLiteral<1>;
103
+ }, z.core.$strict>, z.ZodObject<{
104
+ expiresAt: z.ZodISODateTime;
105
+ requestId: z.ZodUUID;
106
+ type: z.ZodLiteral<"session.expiring">;
107
+ channelId: z.ZodUUID;
108
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
109
+ version: z.ZodLiteral<1>;
110
+ }, z.core.$strict>, z.ZodObject<{
111
+ expiresAt: z.ZodISODateTime;
112
+ replyTo: z.ZodUUID;
113
+ type: z.ZodLiteral<"session.renewed">;
114
+ channelId: z.ZodUUID;
115
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
116
+ version: z.ZodLiteral<1>;
117
+ }, z.core.$strict>, z.ZodObject<{
118
+ height: z.ZodNumber;
119
+ type: z.ZodLiteral<"resize">;
120
+ channelId: z.ZodUUID;
121
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
122
+ version: z.ZodLiteral<1>;
123
+ }, z.core.$strict>], "type">;
124
+ readonly parentMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
125
+ embedUrl: z.ZodURL;
126
+ replyTo: z.ZodUUID;
127
+ requestId: z.ZodUUID;
128
+ type: z.ZodLiteral<"session.renew">;
129
+ channelId: z.ZodUUID;
130
+ protocol: z.ZodLiteral<"vrplatform.embed.lifecycle">;
131
+ version: z.ZodLiteral<1>;
132
+ }, z.core.$strict>], "type">;
133
+ readonly protocol: "vrplatform.embed.lifecycle";
134
+ readonly version: 1;
135
+ };
136
+ export type EmbedLifecycleChannelConnect = z.infer<typeof channelConnectSchema>;
137
+ export type EmbedLifecycleChannelRequest = z.infer<typeof channelRequestSchema>;
138
+ export type EmbedLifecycleIframeMessage = z.infer<typeof iframeMessageSchema>;
139
+ export type EmbedLifecycleParentMessage = z.infer<typeof parentMessageSchema>;
140
+ export {};
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.embedLifecycle = void 0;
4
+ const zod_1 = require("zod");
5
+ const protocol = 'vrplatform.embed.lifecycle';
6
+ const version = 1;
7
+ const envelope = {
8
+ channelId: zod_1.z.uuid(),
9
+ protocol: zod_1.z.literal(protocol),
10
+ version: zod_1.z.literal(version),
11
+ };
12
+ const channelRequestSchema = zod_1.z
13
+ .object({
14
+ ...envelope,
15
+ requestId: zod_1.z.uuid(),
16
+ type: zod_1.z.literal('channel.request'),
17
+ })
18
+ .strict();
19
+ const channelConnectSchema = zod_1.z
20
+ .object({
21
+ ...envelope,
22
+ replyTo: zod_1.z.uuid(),
23
+ type: zod_1.z.literal('channel.connect'),
24
+ })
25
+ .strict();
26
+ const iframeMessageSchema = zod_1.z.discriminatedUnion('type', [
27
+ zod_1.z
28
+ .object({
29
+ ...envelope,
30
+ type: zod_1.z.literal('ready'),
31
+ })
32
+ .strict(),
33
+ zod_1.z
34
+ .object({
35
+ ...envelope,
36
+ code: zod_1.z.enum([
37
+ 'authentication_failed',
38
+ 'access_denied',
39
+ 'session_expired',
40
+ 'renewal_failed',
41
+ 'unsupported_version',
42
+ 'internal_error',
43
+ ]),
44
+ correlationId: zod_1.z.string().min(1).max(128),
45
+ recoverable: zod_1.z.boolean(),
46
+ replyTo: zod_1.z.uuid().optional(),
47
+ type: zod_1.z.literal('error'),
48
+ })
49
+ .strict(),
50
+ zod_1.z
51
+ .object({
52
+ ...envelope,
53
+ expiresAt: zod_1.z.iso.datetime({ offset: true }),
54
+ requestId: zod_1.z.uuid(),
55
+ type: zod_1.z.literal('session.expiring'),
56
+ })
57
+ .strict(),
58
+ zod_1.z
59
+ .object({
60
+ ...envelope,
61
+ expiresAt: zod_1.z.iso.datetime({ offset: true }),
62
+ replyTo: zod_1.z.uuid(),
63
+ type: zod_1.z.literal('session.renewed'),
64
+ })
65
+ .strict(),
66
+ zod_1.z
67
+ .object({
68
+ ...envelope,
69
+ height: zod_1.z.number().int().positive(),
70
+ type: zod_1.z.literal('resize'),
71
+ })
72
+ .strict(),
73
+ ]);
74
+ const parentMessageSchema = zod_1.z.discriminatedUnion('type', [
75
+ zod_1.z
76
+ .object({
77
+ ...envelope,
78
+ embedUrl: zod_1.z.url(),
79
+ replyTo: zod_1.z.uuid(),
80
+ requestId: zod_1.z.uuid(),
81
+ type: zod_1.z.literal('session.renew'),
82
+ })
83
+ .strict(),
84
+ ]);
85
+ exports.embedLifecycle = {
86
+ channelConnectSchema,
87
+ channelRequestSchema,
88
+ iframeMessageSchema,
89
+ parentMessageSchema,
90
+ protocol,
91
+ version,
92
+ };
93
+ //# sourceMappingURL=embed-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed-lifecycle.js","sourceRoot":"src/","sources":["embed-lifecycle.ts"],"names":[],"mappings":";;;AAAA,6BAAwB;AAExB,MAAM,QAAQ,GAAG,4BAA4B,CAAC;AAC9C,MAAM,OAAO,GAAG,CAAC,CAAC;AAClB,MAAM,QAAQ,GAAG;IACf,SAAS,EAAE,OAAC,CAAC,IAAI,EAAE;IACnB,QAAQ,EAAE,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;IAC7B,OAAO,EAAE,OAAC,CAAC,OAAO,CAAC,OAAO,CAAC;CAC5B,CAAC;AACF,MAAM,oBAAoB,GAAG,OAAC;KAC3B,MAAM,CAAC;IACN,GAAG,QAAQ;IACX,SAAS,EAAE,OAAC,CAAC,IAAI,EAAE;IACnB,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC;CACnC,CAAC;KACD,MAAM,EAAE,CAAC;AACZ,MAAM,oBAAoB,GAAG,OAA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AC;QAC3C,OAAO,EAAE,OAAC,CAAC,IAAI,EAAE;QACjB,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC;KACnC,CAAC;SACD,MAAM,EAAE;IACX,OAAC;SACE,MAAM,CAAC;QACN,GAAG,QAAQ;QACX,MAAM,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;QACnC,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,QAAQ,CAAC;KAC1B,CAAC;SACD,MAAM,EAAE;CACZ,CAAC,CAAC;AACH,MAAM,mBAAmB,GAAG,OAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACvD,OAAC;SACE,MAAM,CAAC;QACN,GAAG,QAAQ;QACX,QAAQ,EAAE,OAAC,CAAC,GAAG,EAAE;QACjB,OAAO,EAAE,OAAC,CAAC,IAAI,EAAE;QACjB,SAAS,EAAE,OAAC,CAAC,IAAI,EAAE;QACnB,IAAI,EAAE,OAAC,CAAC,OAAO,CAAC,eAAe,CAAC;KACjC,CAAC;SACD,MAAM,EAAE;CACZ,CAAC,CAAC;AAEU,QAAA,cAAc,GAAG;IAC5B,oBAAoB;IACpB,oBAAoB;IACpB,mBAAmB;IACnB,mBAAmB;IACnB,QAAQ;IACR,OAAO;CACC,CAAC","sourcesContent":["import { z } from 'zod';\n\nconst protocol = 'vrplatform.embed.lifecycle';\nconst version = 1;\nconst envelope = {\n channelId: z.uuid(),\n protocol: z.literal(protocol),\n version: z.literal(version),\n};\nconst channelRequestSchema = z\n .object({\n ...envelope,\n requestId: z.uuid(),\n type: z.literal('channel.request'),\n })\n .strict();\nconst channelConnectSchema = z\n .object({\n ...envelope,\n replyTo: z.uuid(),\n type: z.literal('channel.connect'),\n })\n .strict();\nconst iframeMessageSchema = z.discriminatedUnion('type', [\n z\n .object({\n ...envelope,\n type: z.literal('ready'),\n })\n .strict(),\n z\n .object({\n ...envelope,\n code: z.enum([\n 'authentication_failed',\n 'access_denied',\n 'session_expired',\n 'renewal_failed',\n 'unsupported_version',\n 'internal_error',\n ]),\n correlationId: z.string().min(1).max(128),\n recoverable: z.boolean(),\n replyTo: z.uuid().optional(),\n type: z.literal('error'),\n })\n .strict(),\n z\n .object({\n ...envelope,\n expiresAt: z.iso.datetime({ offset: true }),\n requestId: z.uuid(),\n type: z.literal('session.expiring'),\n })\n .strict(),\n z\n .object({\n ...envelope,\n expiresAt: z.iso.datetime({ offset: true }),\n replyTo: z.uuid(),\n type: z.literal('session.renewed'),\n })\n .strict(),\n z\n .object({\n ...envelope,\n height: z.number().int().positive(),\n type: z.literal('resize'),\n })\n .strict(),\n]);\nconst parentMessageSchema = z.discriminatedUnion('type', [\n z\n .object({\n ...envelope,\n embedUrl: z.url(),\n replyTo: z.uuid(),\n requestId: z.uuid(),\n type: z.literal('session.renew'),\n })\n .strict(),\n]);\n\nexport const embedLifecycle = {\n channelConnectSchema,\n channelRequestSchema,\n iframeMessageSchema,\n parentMessageSchema,\n protocol,\n version,\n} as const;\n\nexport type EmbedLifecycleChannelConnect = z.infer<typeof channelConnectSchema>;\nexport type EmbedLifecycleChannelRequest = z.infer<typeof channelRequestSchema>;\nexport type EmbedLifecycleIframeMessage = z.infer<typeof iframeMessageSchema>;\nexport type EmbedLifecycleParentMessage = z.infer<typeof parentMessageSchema>;\n"]}
@@ -1,4 +1,4 @@
1
- import type { FetchResponse } from './generated/openapi-fetch';
1
+ import type { FetchResponse } from 'openapi-fetch';
2
2
  type E = {
3
3
  code: string;
4
4
  message: string;
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"src/","sources":["error.ts"],"names":[],"mappings":";;;AA+CA,oCAuBC;AAtED,6CAA6C;AAY7C,MAAa,cAAe,SAAQ,KAAK;IAMvC,YAAmB,KAAQ;QACzB,MAAM,OAAO,GACX,KAAK,CAAC,OAAO;YACb;gBACE,KAAK,CAAC,IAAI;gBACV,KAAK,CAAC,MAAM;oBACV,EAAE,GAAG,CAAC,CAAC,CA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AAK;QAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC","sourcesContent":["import { hasValue } from '@vrplatform/utils';\nimport type { FetchResponse } from './generated/openapi-fetch';\n\ntype E = {\n code: string;\n message: string;\n issues?: {\n message: string;\n }[];\n context?: any;\n stack?: any;\n};\nexport class ApiClientError extends Error {\n code: string;\n issues: {\n message: string;\n }[];\n context: any;\n constructor(public error: E) {\n const message =\n error.message ||\n [\n error.code,\n error.issues\n ?.map((x) =>\n [x.message, (x as any).path?.join('->')]\n .filter(hasValue)\n .join(' on ')\n )\n .join(', '),\n ]\n .filter(hasValue)\n .join(': ');\n super(message);\n\n this.code = error.code;\n this.issues = error.issues || [];\n this.context = error.context || {};\n if (error.stack) this.stack = error.stack;\n }\n}\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: T\n): NonNullable<T['data']>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T>\n): Promise<NonNullable<T['data']>>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T> | T\n): Promise<NonNullable<T['data']>> | NonNullable<T['data']> {\n if (response instanceof Promise) {\n return response.then((response) => {\n if (response.response.status === 503) {\n throw new ApiClientError({\n code: 'SERVICE_UNAVAILABLE',\n message: 'Worker resources exceeded.',\n });\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n });\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"src/","sources":["error.ts"],"names":[],"mappings":";;;AA+CA,oCAuBC;AAtED,6CAA6C;AAY7C,MAAa,cAAe,SAAQ,KAAK;IAMvC,YAAmB,KAAQ;QACzB,MAAM,OAAO,GACX,KAAK,CAAC,OAAO;YACb;gBACE,KAAK,CAAC,IAAI;gBACV,KAAK,CAAC,MAAM;oBACV,EAAE,GAAG,CAA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hC,IAAI,KAAK;QAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;IAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;AACvB,CAAC","sourcesContent":["import { hasValue } from '@vrplatform/utils';\nimport type { FetchResponse } from 'openapi-fetch';\n\ntype E = {\n code: string;\n message: string;\n issues?: {\n message: string;\n }[];\n context?: any;\n stack?: any;\n};\nexport class ApiClientError extends Error {\n code: string;\n issues: {\n message: string;\n }[];\n context: any;\n constructor(public error: E) {\n const message =\n error.message ||\n [\n error.code,\n error.issues\n ?.map((x) =>\n [x.message, (x as any).path?.join('->')]\n .filter(hasValue)\n .join(' on ')\n )\n .join(', '),\n ]\n .filter(hasValue)\n .join(': ');\n super(message);\n\n this.code = error.code;\n this.issues = error.issues || [];\n this.context = error.context || {};\n if (error.stack) this.stack = error.stack;\n }\n}\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: T\n): NonNullable<T['data']>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T>\n): Promise<NonNullable<T['data']>>;\nexport function throwIfError<T extends FetchResponse<any, any, any>>(\n response: Promise<T> | T\n): Promise<NonNullable<T['data']>> | NonNullable<T['data']> {\n if (response instanceof Promise) {\n return response.then((response) => {\n if (response.response.status === 503) {\n throw new ApiClientError({\n code: 'SERVICE_UNAVAILABLE',\n message: 'Worker resources exceeded.',\n });\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n });\n }\n\n const error: E = response.error;\n\n if (error) throw new ApiClientError(error);\n return response.data;\n}\n"]}