@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
@@ -1,5 +1,6 @@
1
1
  import type { ApiClient } from './types';
2
2
  export * from './client';
3
+ export * from './embed-lifecycle';
3
4
  export * from './error';
4
5
  export type * from './generated/v1';
5
6
  export * from './routing';
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./client"), exports);
18
+ __exportStar(require("./embed-lifecycle"), exports);
18
19
  __exportStar(require("./error"), exports);
19
20
  __exportStar(require("./routing"), exports);
20
21
  __exportStar(require("./sec"), exports);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,2CAAyB;AACzB,0CAAwB;AAExB,4CAA0B;AAC1B,wCAAsB;AACtB,0CAAwB","sourcesContent":["import type { ApiClient } from './types';\n\nexport * from './client';\nexport * from './error';\nexport type * from './generated/v1';\nexport * from './routing';\nexport * from './sec';\nexport * from './types';\n\nexport type VRPlatformApi = ApiClient;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAEA,2CAAyB;AACzB,oDAAkC;AAClC,0CAAwB;AAExB,4CAA0B;AAC1B,wCAAsB;AACtB,0CAAwB","sourcesContent":["import type { ApiClient } from './types';\n\nexport * from './client';\nexport * from './embed-lifecycle';\nexport * from './error';\nexport type * from './generated/v1';\nexport * from './routing';\nexport * from './sec';\nexport * from './types';\n\nexport type VRPlatformApi = ApiClient;\n"]}
@@ -14,4 +14,9 @@ export declare function resolveTenantRouting({ connectionId, slug, tenantId, aut
14
14
  slug?: string;
15
15
  tenantId?: string;
16
16
  }): Promise<TenantRouting>;
17
+ /**
18
+ * Resolve a tenant's home region and return an API client configured for that
19
+ * regional API. The resolved tenant id is applied to every regional request.
20
+ */
21
+ export declare function useResolvedApiClient({ connectionId, slug, tenantId, auth, ...apiClientOptions }: Parameters<typeof resolveTenantRouting>[0]): Promise<import("./types").ApiClient>;
17
22
  export {};
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.resolveTenantRouting = resolveTenantRouting;
4
+ exports.useResolvedApiClient = useResolvedApiClient;
4
5
  const client_1 = require("./client");
5
6
  const error_1 = require("./error");
6
7
  /**
@@ -37,4 +38,25 @@ async function resolveTenantRouting({ connectionId, slug, tenantId, auth, ...api
37
38
  apiBaseUrl: new URL(response.apiBaseUrl).toString().replace(/\/$/, ''),
38
39
  };
39
40
  }
41
+ /**
42
+ * Resolve a tenant's home region and return an API client configured for that
43
+ * regional API. The resolved tenant id is applied to every regional request.
44
+ */
45
+ async function useResolvedApiClient({ connectionId, slug, tenantId, auth, ...apiClientOptions }) {
46
+ const routing = await resolveTenantRouting({
47
+ ...apiClientOptions,
48
+ connectionId,
49
+ slug,
50
+ tenantId,
51
+ auth,
52
+ });
53
+ return (0, client_1.useApiClient)({
54
+ ...apiClientOptions,
55
+ baseUrl: routing.apiBaseUrl,
56
+ auth: () => ({
57
+ ...(typeof auth === 'function' ? auth() : (auth ?? {})),
58
+ tenantId: routing.id,
59
+ }),
60
+ });
61
+ }
40
62
  //# sourceMappingURL=routing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"routing.js","sourceRoot":"src/","sources":["routing.ts"],"names":[],"mappings":";;AAkBA,oDAwCC;AA1DD,qCAAwC;AACxC,mCAAuC;AAUvC;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CAAC,EACzC,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,GAAG,gBAAgB,EAKpB;IACC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,QAAQ,GAAG,IAAA,oBAAY,EAC3B,MAAM,IAAA,qBAAY,EAAC;QACjB,GAAG,gBAAgB;QACnB,IAAI,EAAE,QAAQ;YACZ,CAAC,CAAC,GAAG,EAAE;gBACH,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;gBACnE,OAAO;oBACL,GAAG,OAAO;oBACV,QAAQ;iBACe,CAAC;YAC5B,CAAC;YACH,CAAC,CAAC,IAAI;KACT,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE;QACvB,MAAM,EAAE;YACN,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE;SAC9D;KACF,CAAC,CACH,CAAC;IAEF,OAAO;QACL,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,UAAU,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;KACvE,CAAC;AACJ,CAAC","sourcesContent":["import { useApiClient } from './client';\nimport { throwIfError } from './error';\nimport type { ApiClientAuth, ResponseData } from './types';\n\nexport type TenantRouting = Pick<\n ResponseData<'get:/teams/resolve'>,\n 'id' | 'slug' | 'dataRegion' | 'apiBaseUrl'\n>;\n\ntype ApiClientOptions = Parameters<typeof useApiClient>[0];\n\n/**\n * Resolve a tenant's region and regional `apiBaseUrl` from a connection id,\n * slug, or tenant id — the client entry point for non-API runtimes that need\n * to reach a tenant's home region. Each call is a `/teams/resolve` round trip;\n * hot-loop callers should cache the result (placement changes only on an\n * explicit tenant migration).\n */\nexport async function resolveTenantRouting({\n connectionId,\n slug,\n tenantId,\n auth,\n ...apiClientOptions\n}: ApiClientOptions & {\n connectionId?: string;\n slug?: string;\n tenantId?: string;\n}): Promise<TenantRouting> {\n if (!connectionId && !slug && !tenantId) {\n throw new Error('connectionId, slug, or tenantId is required');\n }\n\n const response = throwIfError(\n await useApiClient({\n ...apiClientOptions,\n auth: tenantId\n ? () => {\n const current = typeof auth === 'function' ? auth() : (auth ?? {});\n return {\n ...current,\n tenantId,\n } satisfies ApiClientAuth;\n }\n : auth,\n }).GET('/teams/resolve', {\n params: {\n query: slug ? { slug } : connectionId ? { connectionId } : {},\n },\n })\n );\n\n return {\n id: response.id,\n slug: response.slug,\n dataRegion: response.dataRegion,\n apiBaseUrl: new URL(response.apiBaseUrl).toString().replace(/\\/$/, ''),\n };\n}\n"]}
1
+ {"version":3,"file":"routing.js","sourceRoot":"src/","sources":["routing.ts"],"names":[],"mappings":";;AAkBA,oDAwCC;AAMD,oDAwBC;AAxFD,qCAAwC;AACxC,mCAAuC;AAUvC;;;;;;GAMG;AACI,KAAK,UAAU,oBAAoB,CAAC,EACzC,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,GAAG,gBAAgB,EAKpB;IACC,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,QAAQ,GAAG,IAAA,oBAAY,EAC3B,MAAM,IAAA,qBAAY,EAAC;QACjB,GAAG,gBAAgB;QACnB,IAAI,EAAE,QAAQ;YACZ,CAAC,CAAC,GAAG,EAAE;gBACH,MAAM,OAAO,GAAG,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;gBACnE,OAAO;oBACL,GAAG,OAAO;oBACV,QAAQ;iBACe,CAAC;YAC5B,CAAC;YACH,CAAC,CAAC,IAAI;KACT,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE;QACvB,MAAM,EAAE;YACN,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE;SAC9D;KACF,CAAC,CACH,CAAC;IAEF,OAAO;QACL,EAAE,EAAE,QAAQ,CAAC,EAAE;QACf,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,UAAU,EAAE,IAAI,GAAG,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;KACvE,CAAC;AACJ,CAAC;AAED;;;GAGG;AACI,KAAK,UAAU,oBAAoB,CAAC,EACzC,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,IAAI,EACJ,GAAG,gBAAgB,EACwB;IAC3C,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC;QACzC,GAAG,gBAAgB;QACnB,YAAY;QACZ,IAAI;QACJ,QAAQ;QACR,IAAI;KACL,CAAC,CAAC;IAEH,OAAO,IAAA,qBAAY,EAAC;QAClB,GAAG,gBAAgB;QACnB,OAAO,EAAE,OAAO,CAAC,UAAU;QAC3B,IAAI,EAAE,GAAG,EAAE,CACT,CAAC;YACC,GAAG,CAAC,OAAO,IAAI,KAAK,UAAU,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;YACvD,QAAQ,EAAE,OAAO,CAAC,EAAE;SACrB,CAAyB;KAC7B,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { useApiClient } from './client';\nimport { throwIfError } from './error';\nimport type { ApiClientAuth, ResponseData } from './types';\n\nexport type TenantRouting = Pick<\n ResponseData<'get:/teams/resolve'>,\n 'id' | 'slug' | 'dataRegion' | 'apiBaseUrl'\n>;\n\ntype ApiClientOptions = Parameters<typeof useApiClient>[0];\n\n/**\n * Resolve a tenant's region and regional `apiBaseUrl` from a connection id,\n * slug, or tenant id — the client entry point for non-API runtimes that need\n * to reach a tenant's home region. Each call is a `/teams/resolve` round trip;\n * hot-loop callers should cache the result (placement changes only on an\n * explicit tenant migration).\n */\nexport async function resolveTenantRouting({\n connectionId,\n slug,\n tenantId,\n auth,\n ...apiClientOptions\n}: ApiClientOptions & {\n connectionId?: string;\n slug?: string;\n tenantId?: string;\n}): Promise<TenantRouting> {\n if (!connectionId && !slug && !tenantId) {\n throw new Error('connectionId, slug, or tenantId is required');\n }\n\n const response = throwIfError(\n await useApiClient({\n ...apiClientOptions,\n auth: tenantId\n ? () => {\n const current = typeof auth === 'function' ? auth() : (auth ?? {});\n return {\n ...current,\n tenantId,\n } satisfies ApiClientAuth;\n }\n : auth,\n }).GET('/teams/resolve', {\n params: {\n query: slug ? { slug } : connectionId ? { connectionId } : {},\n },\n })\n );\n\n return {\n id: response.id,\n slug: response.slug,\n dataRegion: response.dataRegion,\n apiBaseUrl: new URL(response.apiBaseUrl).toString().replace(/\\/$/, ''),\n };\n}\n\n/**\n * Resolve a tenant's home region and return an API client configured for that\n * regional API. The resolved tenant id is applied to every regional request.\n */\nexport async function useResolvedApiClient({\n connectionId,\n slug,\n tenantId,\n auth,\n ...apiClientOptions\n}: Parameters<typeof resolveTenantRouting>[0]) {\n const routing = await resolveTenantRouting({\n ...apiClientOptions,\n connectionId,\n slug,\n tenantId,\n auth,\n });\n\n return useApiClient({\n ...apiClientOptions,\n baseUrl: routing.apiBaseUrl,\n auth: () =>\n ({\n ...(typeof auth === 'function' ? auth() : (auth ?? {})),\n tenantId: routing.id,\n }) satisfies ApiClientAuth,\n });\n}\n"]}
@@ -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,90 @@
1
+ import { z } from 'zod';
2
+ const protocol = 'vrplatform.embed.lifecycle';
3
+ const version = 1;
4
+ const envelope = {
5
+ channelId: z.uuid(),
6
+ protocol: z.literal(protocol),
7
+ version: z.literal(version),
8
+ };
9
+ const channelRequestSchema = z
10
+ .object({
11
+ ...envelope,
12
+ requestId: z.uuid(),
13
+ type: z.literal('channel.request'),
14
+ })
15
+ .strict();
16
+ const channelConnectSchema = z
17
+ .object({
18
+ ...envelope,
19
+ replyTo: z.uuid(),
20
+ type: z.literal('channel.connect'),
21
+ })
22
+ .strict();
23
+ const iframeMessageSchema = z.discriminatedUnion('type', [
24
+ z
25
+ .object({
26
+ ...envelope,
27
+ type: z.literal('ready'),
28
+ })
29
+ .strict(),
30
+ z
31
+ .object({
32
+ ...envelope,
33
+ code: z.enum([
34
+ 'authentication_failed',
35
+ 'access_denied',
36
+ 'session_expired',
37
+ 'renewal_failed',
38
+ 'unsupported_version',
39
+ 'internal_error',
40
+ ]),
41
+ correlationId: z.string().min(1).max(128),
42
+ recoverable: z.boolean(),
43
+ replyTo: z.uuid().optional(),
44
+ type: z.literal('error'),
45
+ })
46
+ .strict(),
47
+ z
48
+ .object({
49
+ ...envelope,
50
+ expiresAt: z.iso.datetime({ offset: true }),
51
+ requestId: z.uuid(),
52
+ type: z.literal('session.expiring'),
53
+ })
54
+ .strict(),
55
+ z
56
+ .object({
57
+ ...envelope,
58
+ expiresAt: z.iso.datetime({ offset: true }),
59
+ replyTo: z.uuid(),
60
+ type: z.literal('session.renewed'),
61
+ })
62
+ .strict(),
63
+ z
64
+ .object({
65
+ ...envelope,
66
+ height: z.number().int().positive(),
67
+ type: z.literal('resize'),
68
+ })
69
+ .strict(),
70
+ ]);
71
+ const parentMessageSchema = z.discriminatedUnion('type', [
72
+ z
73
+ .object({
74
+ ...envelope,
75
+ embedUrl: z.url(),
76
+ replyTo: z.uuid(),
77
+ requestId: z.uuid(),
78
+ type: z.literal('session.renew'),
79
+ })
80
+ .strict(),
81
+ ]);
82
+ export const embedLifecycle = {
83
+ channelConnectSchema,
84
+ channelRequestSchema,
85
+ iframeMessageSchema,
86
+ parentMessageSchema,
87
+ protocol,
88
+ version,
89
+ };
90
+ //# sourceMappingURL=embed-lifecycle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"embed-lifecycle.js","sourceRoot":"src/","sources":["embed-lifecycle.ts"],"names":[],"mappings":"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","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":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAY7C,MAAM,OAAO,cAAe,SAAQ,KAAK;IAMpB;IALnB,IAAI,CAAS;IACb,MAAM,CAEF;IACJ,OAAO,CAAM;IACb,YAAmB,KAAQ;QACzB,MAAM,OAAO,GACX,KAAK,CAAC,OAAO;YACb;gBACE,KAAK,CAAC,IAAI;gBACV,KAAK,CAAC,MAAM;oBACV,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACV,CAAC,CAAC,CAAC,OAAO,EAAG,CAAS,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;qBACrC,MAAM,CAAC,QAAQ,CAAC;qBAChB,IAAI,CAAC,MAAM,CAAC,CAChB;qBACA,IAAI,CAAC,IAAI,CAAC;aACd;iBACE,MAAM,CAAC,QAAQ,CAAC;iBAChB,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,KAAK,CAAC,OAAO,CAAC,CAAC;QAfE,UAAK,GAAL,KAAK,CAAG;QAiBzB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,IAAI,KAAK,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC5C,CAAC;CACF;AAOD,MAAM,UAAU,YAAY,CAC1B,QAAwB;IAExB,IAAI,QAAQ,YAAY,OAAO,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACrC,MAAM,IAAI,cAAc,CAAC;oBACvB,IAAI,EAAE,qBAAqB;oBAC3B,OAAO,EAAE,4BAA4B;iBACtC,CAAC,CAAC;YACL,CAAC;YAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;YAEhC,IAAI,KAAK;gBAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;IAEhC,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 './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":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAY7C,MAAM,OAAO,cAAe,SAAQ,KAAK;IAMpB;IALnB,IAAI,CAAS;IACb,MAAM,CAEF;IACJ,OAAO,CAAM;IACb,YAAmB,KAAQ;QACzB,MAAM,OAAO,GACX,KAAK,CAAC,OAAO;YACb;gBACE,KAAK,CAAC,IAAI;gBACV,KAAK,CAAC,MAAM;oBACV,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CACV,CAAC,CAAC,CAAC,OAAO,EAAG,CAAS,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;qBACrC,MAAM,CAAC,QAAQ,CAAC;qBAChB,IAAI,CAAC,MAAM,CAAC,CAChB;qBACA,IAAI,CAAC,IAAI,CAAC;aACd;iBACE,MAAM,CAAC,QAAQ,CAAC;iBAChB,IAAI,CAAC,IAAI,CAAC,CAAC;QAChB,KAAK,CAAC,OAAO,CAAC,CAAC;QAfE,UAAK,GAAL,KAAK,CAAG;QAiBzB,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,IAAI,EAAE,CAAC;QACjC,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;QACnC,IAAI,KAAK,CAAC,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAC5C,CAAC;CACF;AAOD,MAAM,UAAU,YAAY,CAC1B,QAAwB;IAExB,IAAI,QAAQ,YAAY,OAAO,EAAE,CAAC;QAChC,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,EAAE;YAChC,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACrC,MAAM,IAAI,cAAc,CAAC;oBACvB,IAAI,EAAE,qBAAqB;oBAC3B,OAAO,EAAE,4BAA4B;iBACtC,CAAC,CAAC;YACL,CAAC;YAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;YAEhC,IAAI,KAAK;gBAAE,MAAM,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC;YAC3C,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,MAAM,KAAK,GAAM,QAAQ,CAAC,KAAK,CAAC;IAEhC,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"]}